The reason you wont get much results is that most of the contacts are stored as leads.
You have to search both.
I dont do php, but here's the sql I used when I wrote a .net app. It works.
Yeah it's huge!!! really messy database schema.
where you find '" & Trim(strPhone) & "' replace it with variable containing the phone number you are searching.
If you want tosearch on a different variable you should be able to figure it out from there.
strSql = "SELECT vtiger_contactdetails.firstname AS FirstName,vtiger_contactdetails.lastname AS Surname, vtiger_account.accountname AS Company, vtiger_contactdetails.phone AS Telephone, vtiger_contactdetails.mobile AS Cellphone, vtiger_contactdetails.contactid AS CRMID,vtiger_contactdetails.email as Email FROM vtiger_potential INNER JOIN vtiger_account ON (vtiger_potential.accountid = vtiger_account.accountid) INNER JOIN vtiger_contpotentialrel ON (vtiger_potential.potentialid = vtiger_contpotentialrel.potentialid) INNER JOIN vtiger_contactdetails ON (vtiger_contactdetails.accountid = vtiger_account.accountid) WHERE vtiger_contactdetails.phone = '" & Trim(strPhone) & "' OR vtiger_contactdetails.mobile = '" & Trim(strPhone) & "' OR vtiger_account.phone = '" & Trim(strPhone) & "' OR vtiger_account.otherphone = '" & Trim(strPhone) & "' UNION SELECT vtiger_leaddetails.firstname AS FirstName,vtiger_leaddetails.lastname AS Surname, vtiger_leaddetails.company AS Company, vtiger_leadaddress.phone AS Telephone,vtiger_leadaddress.mobile AS cellphone,vtiger_crmentity.crmid,vtiger_leaddetails.email AS CRMID FROM vtiger_leaddetails INNER JOIN vtiger_crmentity ON (vtiger_crmentity.crmid = vtiger_leaddetails.leadid)INNER JOIN vtiger_leadsubdetails ON (vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid)INNER JOIN vtiger_leadaddress ON (vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid)INNER JOIN vtiger_leadscf ON (vtiger_leaddetails.leadid = vtiger_leadscf.leadid)LEFT OUTER JOIN vtiger_groups ON (vtiger_groups.groupid = vtiger_crmentity.smownerid)LEFT OUTER JOIN vtiger_users ON (vtiger_users.id = vtiger_crmentity.smownerid)WHERE vtiger_crmentity.deleted = 0 AND vtiger_leaddetails.converted = 0 AND (vtiger_leadaddress.phone = '" & Trim(strPhone) & "' OR vtiger_leadaddress.mobile = '" & Trim(strPhone) & "')"
The reason I use unions is to line up results in a grid control, it should work fine though.
I'd like to use the vtiger scripts too. Which script is it and I'll take a look at it?
Ed
www.voipsure.com