Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.