how multiple search in single input

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aris1234
Forum Newbie
Posts: 11
Joined: Mon May 07, 2007 7:10 am

how multiple search in single input

Post by aris1234 »

Hi All...

how searching by name or email or no telp in single input (box) ??

its code my html form

Code: Select all

<form action="result.php" method="POST">
   <input type="text" name="find" >
   <input type="submit" name="search" value="search" >
</form>

i use php code like this :

Code: Select all

$find	= $_POST["find"];  // from  name input type in form

$query 	= "SELECT * FROM register WHERE name_child AND email AND nohp LIKE '%$find%' ORDER BY name_child ASC";
$NumResult = mysql_query($query);
$result	= mysql_numrows($NumResult);
that code above no have result, and i try like below this have same result :

Code: Select all

$query 	= "SELECT * FROM register WHERE name_child LIKE '%$find%' AND email LIKE '%$find%' AND nohp LIKE '%$find%' ORDER BY name_child ASC";
$NumResult = mysql_query($query);
$result	= mysql_numrows($NumResult);
im try too using OR but result have same

please help me the solotion
thinsoldier
Forum Contributor
Posts: 367
Joined: Fri Jul 20, 2007 11:29 am
Contact:

Post by thinsoldier »

Code: Select all

$query  = "SELECT * FROM register 
WHERE (name_child LIKE '%$find%') 
OR (email LIKE '%$find%') 
OR (nohp LIKE '%$find%')
ORDER BY name_child ASC";
maybe
aris1234
Forum Newbie
Posts: 11
Joined: Mon May 07, 2007 7:10 am

Post by aris1234 »

that code work ...

thanks

:wink: soldeir
Post Reply