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. Quote Link to comment 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. Quote Link to comment 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.