FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Seach MySQl for muiltipe variables

 


flatliner
OK well I have a html seach box with 5 user inputs and then I want to seach for them in my mysql database. here is the code I have so far, but for the seachs with a combination of 2 variables I cant get it to work, just look at the code it will make more sence.

Code:

$byapplicantname  = $_POST[byapplicantname];
$bybuildername  = $_POST[bybuildername];
$bydevelopment_type = $_POST[development_type];
$bydescription_keywords = $_POST[description_keywords];
$bylocation = $_POST[bylocation];
$emtpy = "";



if(($bylocation == $emtpy)&($bydescription_keywords == $emtpy))
{}
else
{// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION AND DEVELOPMENT_DESCRIPTION  LIKE '%$bylocation%' AND '%$bydescription_keywords%' ")
or die(mysql_error());};

/////////////////////////////////////////////////////////

 if(($bylocation == $emtpy)&($bydevelopment_type == $emtpy))
{}
else
{// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION AND DEVELOPMENT_TYPE  LIKE '%$bylocation%' AND '%$$bydevelopment_type%' ")
or die(mysql_error());};

///////////////////////////////////////////////////////////////


Any ideas?


Yours Thankfully
Ciaran Mc Cann
Fire Boar
Bad mysql syntax.

Code:
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION AND DEVELOPMENT_DESCRIPTION  LIKE '%$bylocation%' AND '%$bydescription_keywords%' ")
or die(mysql_error());


It should be:

Code:
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION LIKE '%$bylocation%' AND DEVELOPMENT_DESCRIPTION LIKE '%$bydescription_keywords%' ")
or die(mysql_error());


From that you should be able to sort the rest out yourself.

Cheers,
FB.
flatliner
Ah yea thats it thanks very much. Very Happy
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.