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 Link to comment https://forums.phpfreaks.com/topic/275400-how-to-correct-it/ 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". Link to comment https://forums.phpfreaks.com/topic/275400-how-to-correct-it/#findComment-1417458 Share on other sites More sharing options...
spluskhan Posted March 8, 2013 Author Share Posted March 8, 2013 if u give me sme example Link to comment https://forums.phpfreaks.com/topic/275400-how-to-correct-it/#findComment-1417461 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 Link to comment https://forums.phpfreaks.com/topic/275400-how-to-correct-it/#findComment-1417463 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. Link to comment https://forums.phpfreaks.com/topic/275400-how-to-correct-it/#findComment-1417466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.