#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    347
    Rep Power
    15

    simple search query


    i'm using this search query to draw data from my mySQL db, however for certain words it retrieves nothing.
    For example, a search for epson returns all epson products whilst a search string of lexmark returns nothing, whether spelt with a capital letter or not

    PHP Code:
    $sql "SELECT * FROM products WHERE UPPER(CONCAT(`productid` , `brand` , `code` , `printer` , `rrp` , `price` , `availability` , `status` , `type` , `productsort` , `category` , `view` )) LIKE UPPER('%$keysearchstr%') LIMIT 0, 30"
    I wanted to add to the functionality of this engine anyway, i found a piece of code that appears to do something i wanted to implement but i also cant make it work. What i want the engine to do is this. if the first search returns no results then query the db again, if the user has entered a word with more than a few characters take the first and last letter of the search string and wildcard all the others to allow for most spelling mistakes(i know the code i've found doesnt do this!).

    this was the other code i found but i couldnt make it work at all. the sql itself was the problem though i think because thats where the error was.
    PHP Code:
    $split_search explode(" ",$keysearchstr); 
            for(
    $i 0$i count($split_search); $i++) 
            { 
            
    $sql "SELECT * FROM products WHERE `productid` , `brand` , `code` , `printer` , `rrp` , `price` , `availability` , `status` , `type` , `productsort` , `category` , `view` LIKE '%$split_search[$i]%'  LIMIT 0, 30";


    Any ideas how i could take either of these forward would be massively appreciated
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    347
    Rep Power
    15
    any ideas?

IMN logo majestic logo threadwatch logo seochat tools logo