redarrow Posted May 20, 2006 Share Posted May 20, 2006 What i need to no what is the best way to get a search feature that will let the database search using allform boxs example, pulldown and input boxfrom 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[code]WHERE fname = '%"fname"%' AND address='%"address"%' AND price='%"price"' [/code]seach example for 1 input box[code]//connect to database for data result useing like and %wildcard for name search$db=mysql_connect("localhost","xxxx","xxxx");mysql_select_db("xxxx" , $db);$query="select pro_membersu.fname , pro_membersu.birthday , pro_membersu.email from pro_membersu where fname like '%".$name."%'";$result=mysql_query($query);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10048-search-query-quistion/ Share on other sites More sharing options...
dsk3801 Posted May 20, 2006 Share Posted May 20, 2006 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}%';"; Quote Link to comment https://forums.phpfreaks.com/topic/10048-search-query-quistion/#findComment-37454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.