newsamsu Posted April 10, 2008 Share Posted April 10, 2008 :'( hi there, im just wondering if anyone can help me with creating a simple search using php. i have a table in mysql and want to be able to search using the name of the person that is in the table. can anyone help me with the code of how to create such a thing. thank you Link to comment https://forums.phpfreaks.com/topic/100525-simple-search-query/ Share on other sites More sharing options...
p2grace Posted April 10, 2008 Share Posted April 10, 2008 You'd use like statements in the query. <?php $search_str = "bob"; $query = "SELECT `name` FROM `users` WHERE LOWER(`name`) LIKE LOWER('%$search_str%')"; $run = mysql_query($query); if($run){ while($arr = mysql_fetch_assoc($run)){ extract($arr); echo "name = $name<br />"; } } else{ die("Unable to connect to database."); } ?> This is obviously a very simple example, but it's enough to get you started. Link to comment https://forums.phpfreaks.com/topic/100525-simple-search-query/#findComment-514167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.