How is it i would code something so that it searches a database for words (basically a search bar)?
How is it i would code something so that it searches a database for words (basically a search bar)?
Coming and going...
Highers are getting the better of me
$sql = mysql_query( "SELECT * FROM `database` WHERE `fieldname` LIKE '%' . $search . '%' ");
should work.
You don't need to use the %
Plus if you want to search multiple fields use this:
etcPHP Code:$sql = mysql_query( "SELECT * FROM `database` WHERE `fieldname` LIKE $search OR `fieldname2` LIKE $search OR `fieldname3` LIKE $search");
If you have % it allows to search for the search to ignore the leading characters and the characters following the search string.
See
http://www.weberdev.com/ViewArticle.php3?ArticleID=81
Want to hide these adverts? Register an account for free!