Pain Posted March 22, 2012 Share Posted March 22, 2012 Hi there. I am trying to implement a simple search system for my web. When the user inputs some text into a search box then mysql starts querying the database. Example: <?php $query2 = mysql_query("SELECT * FROM products WHERE product_name = '$search'"); while ($row = mysql_fetch_assoc($query2)) { $product_name = $row['product_name']; echo $product_name; } ?> So i my question would be: how to return a line which says "no results were found" if the keyword does not mach anything from the db. Thanks:) Quote Link to comment Share on other sites More sharing options...
Pain Posted March 22, 2012 Author Share Posted March 22, 2012 I've found a solution. Anyway there's another question on my mind. I only get the exact results from my search. For example if i type in 'samsung galaxy tab' to my seach box, i get back 'samsung galaxy tab'. However it would be great to be able to type in 'samsung galaxy' and get a back 'samsung galaxy tab' (at the moment i get no results). How can i sort this out? Thanks:) EDIT: I've done it by using LIKE 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.