rlgriffo Posted August 6, 2008 Share Posted August 6, 2008 Hi, I am a complete newbie to PHP & mysql. I have created a database for my website...i want to be able to search the database for a keyword eg "hairdresser" and for it to return all the entries which include this keyword. I don't want people to see a search box or anything, i just want the results to be sitting there for them when they open that page. I have learnt what i know so far (not much) from online tutorials, however i cant seem to find any information on how to display the data i have in my table in this manner. If anyone could help me, provide me with some code or direct me to a online tutorial or something i would really appreciate it. Link to comment https://forums.phpfreaks.com/topic/118444-search-database-and-display-results-on-website/ Share on other sites More sharing options...
Xurion Posted August 6, 2008 Share Posted August 6, 2008 I'll assume you know how to connect to a database etc and I'll just write the query & display code: $result = mysql_query("SELECT * FROM yourtable WHERE yourcolumn LIKE '%hairdresser%'"); while($row = mysql_fetch_assoc($result){ echo 'Hairdresser found in '.$row['yourcolumn'].' with the id of '.$row['id'].'<br>'; } This code queries the database and displays the results as a new line. This script assumes you have a column called id. Link to comment https://forums.phpfreaks.com/topic/118444-search-database-and-display-results-on-website/#findComment-609675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.