aashcool198 Posted June 12, 2009 Share Posted June 12, 2009 hi.. i am trying to make a small search engine. where user fills value in form and it is searched in database. $text = $_POST['search']; $q = "SELECT name_id, firstname, lastname FROM personal where firstname LIKE '%'$text'%'"; $query = mysql_query($q); while($row = mysql_fetch_array($query)){ echo $row['firstname']; I think there is some problem with LIKE '%'$text'%'. please tell me the right syntax. Quote Link to comment https://forums.phpfreaks.com/topic/161910-solved-searching-in-database/ Share on other sites More sharing options...
Dathremar Posted June 12, 2009 Share Posted June 12, 2009 $q = "SELECT name_id, firstname, lastname FROM personal where firstname LIKE '%".$text."%'"; But I recommend to check $_POST['search'] if it contains the desired information, before You use it in the query. Quote Link to comment https://forums.phpfreaks.com/topic/161910-solved-searching-in-database/#findComment-854267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.