FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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
Related topics
E-Cards with PHP & MySQL
HTTP AUTH with PHP and mySQL
Separating contents of MySQL row and put them in variables?
A very good PHP MySQL Tutorial
MySQL HELP!!
[man]Azlo tu mismo ShoutBox en PHP y mysql
how do I use pear pager with a mysql resultset
Need Help integrating php variable into mySQL SELECT query
Developing a Login System with PHP and MySQL
MySQL Set-up Structure - Help!!!
Simple php & mysql script
Mysql seach for 4 argument or 1 or any conbination of them??
whats wrong with this mysql query?
MySQL Query Cache
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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