Jump to content


This topic is now archived and is closed to further replies.


search query quistion

Recommended Posts

What i need to no what is the best way to get a search feature that will let the database search using all
form boxs example, pulldown and input box

from my below code the database gets searched via the name and the word name comes from the varable name in the form input box,

so if you had lots of search features how do you add them example.

do you just add afther the WHERE clause other AND that relate to the input form name or the pulldown option name this is to save on querys or do you add lots and lots of querys.

example for 2 input boxs and 1 pulldown box
WHERE fname = '%"fname"%' AND address='%"address"%' AND price='%"price"'  

seach example for 1 input box

//connect to database for data result useing like and %wildcard for name search

mysql_select_db("xxxx" , $db);
$query="select pro_membersu.fname , pro_membersu.birthday , pro_membersu.email from pro_membersu where fname like '%".$name."%'";


Share this post

Link to post
Share on other sites
I wonder if this would work?

$sql = "select `fname`, `birthday`, `email` from `pro_membersu` where `fname` like '%{$name}%' and `address` like '%{$address}%' and `price` like '%{$price}%';";

alternatively, if you just want to match when one or more conditions are found, then you could use or instead of and:

$sql = "select `fname`, `birthday`, `email` from `pro_membersu` where `fname` like '%{$name}%' or `address` like '%{$address}%' or `price` like '%{$price}%';";

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.