www.webdeveloper.com
Results 1 to 2 of 2

Thread: Nee help for this code

  1. #1
    Join Date
    Mar 2013
    Posts
    1

    Lightbulb Nee help for this code

    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..

    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

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    That's what a WHERE clause is for in your SQL. If you need to support "fuzzy" searches based on whatever text a user enters, you may want to look into using FULLTEXT indexes and their related function in your database and SQL.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles