Search query problem
Posted: Mon Aug 07, 2006 11:11 am
OK
The name Merrill Lynch is stored in two tables.
When I use this code to search for the value Merrill or similar I find the record:
Code is:
But when I use a variat of the smae code to search for Merill or similar in the other table It wont find the record
Code is:
Why is this happening
The name Merrill Lynch is stored in two tables.
When I use this code to search for the value Merrill or similar I find the record:
Code is:
Code: Select all
// the query used to search the DB
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
$query = "SELECT
o.org_id,o.web_url,
p.person_id,p.org_id,p.salutation,p.firstname,p.surname,
p.organisation,p.role,p.address1,p.address2,p.city,
p.postcode,p.telephone,p.mobile,p.fax,p.dateoflastcontact,
p.datecontactagain,p.email,
DATE_FORMAT(dateoflastcontact, '%M/%Y')
AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%M/%Y')
AS datecontactagain
FROM people p LEFT JOIN organisations o
ON o.org_id = p.org_id
WHERE organisation LIKE '$formVars[organisation]%'";
$result = mysql_query($query);Code is:
Code: Select all
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
$query = "SELECT
orgname, web_url,sector,org_id,person_id,
notes FROM organisations
WHERE orgname LIKE '$formVars[orgname]%' ORDER BY orgname ASC ";
$result = mysql_query($query);