Search data in mysql and display the data

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
misznofa
Forum Newbie
Posts: 1
Joined: Mon May 15, 2006 8:28 pm

Search data in mysql and display the data

Post by misznofa »

Does anyone knows how to do a search function coding? I couldn't manage to find the code. I want to search data in mysql database and display the results in table. Please help me..coz i'm a beginner in PHP. :cry:
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

there are many ways to do it.

The best way for a new programmer is:

Code: Select all

$value = "search value";
$sql = "SELECT * FROM table WHERE field LIKE '%$value%'";
The %s act as wildcards, similar to * in windows/linux/whatever - so you will be returned all rows in which the `field` value contains the search string in it.
Post Reply