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. 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. Link to comment https://forums.phpfreaks.com/topic/161910-solved-searching-in-database/#findComment-854267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.