spluskhan Posted March 8, 2013 Share Posted March 8, 2013 suppose i have 10 products in my database Example: iphone 2 - iphone 3g - laptop i3 - laptop i7 - nokia n96 etc when i enter iphone in my search i see all records stored in database thats my prob! what i want ? suppose if i enter laptop i7 or laptop then i get result for laptop i7 or laptop here is my code.. <?php // Connects to your Database mysql_connect("host.com", "userr", "pass") or die(mysql_error()); mysql_select_db("products") or die(mysql_error()); $data = mysql_query("SELECT * FROM Products") or die(mysql_error()); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<th>Name:</th> <td>".$info['name'] . "</td> "; Print "<th>new:</th> <td>".$info['new_price'] . "</td> "; Print "<th>old:</th> <td>".$info['old_proce'] . "</td> "; Print "<th>faulty:</th> <td>".$info['Faulty_price'] . " </td></tr>"; } Print "</table>"; ?> if any one have better code then please give me tankxx Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 8, 2013 Share Posted March 8, 2013 You need to read up a bit on MySQL's LIKE function. Here's the official manual entry on it, and while it might be a bit confusing at first I recommend playing around with the examples. If you need more examples, there's plenty out there if you search for "mysql like". Quote Link to comment Share on other sites More sharing options...
spluskhan Posted March 8, 2013 Author Share Posted March 8, 2013 if u give me sme example Quote Link to comment Share on other sites More sharing options...
spluskhan Posted March 8, 2013 Author Share Posted March 8, 2013 im new n php if u give me code thats wll b gr8 Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 8, 2013 Share Posted March 8, 2013 Follow the link, and you'll find lots of examples. Search the web, as I suggested, and you'll find millions of examples. Generally you'll find that the effort people put into helping you, is directly proportional to the (perceived) effort you've put into solving/finding the answer on your own. This includes your grammar and spelling. 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.