954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Php Mysql : Code for Multiple Field Search

What would be the php mysql code to search more than 1 field in a table ?

Im trying to search for a given partial phone number in all three fields home mobile and work ..

im trying to use

$query = "SELECT `first`, `last`, `home_phone` , `work_phone` , `mobile_phone` FROM `profiles` WHERE LIKE '%516353%'

but this returns everything thats in the table

Any help would be appreciated

isomillennium
Light Poster
25 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
 
$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";
nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 
$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";


thatnk it worked fine i just had to change OR TO ||

isomillennium
Light Poster
25 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
 

:) It should work with OR.. But anyway, cheers!

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You