Page 1 of 1

Search data in mysql and display the data

Posted: Mon May 15, 2006 8:35 pm
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:

Posted: Mon May 15, 2006 8:51 pm
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.