Jump to content


search query quistion

  • Please log in to reply
1 reply to this topic

#1 redarrow

  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 May 2006 - 02:27 AM

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."%'";

Wish i new all about php DAM i will have to learn

#2 dsk3801

  • New Members
  • Pip
  • Newbie
  • 9 posts
  • LocationDallas, TX USA

Posted 20 May 2006 - 04:32 PM

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}%';";

Instant Access - PHP5 / MySQL5 Web Hosting Starting At $2.99 / Month - [a href="http://www.reflex-hosting.com" target="_blank"]http://www.reflex-hosting.com[/a]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users