Re: select query help
Here is an example:
$string = "lether shooo";
$words = str_word_count($string,1);
//for debug you can check the words
//print_r($words);
$moreSQL = "";
foreach($words as $word) {
$moreSQL .= " AND (prodname like '%".mysql_real_escape_string($word)."%' OR skuno LIKE '%".mysql_real_escape_string($word)."%') ";
}
$sqlQuery = "SELECT * FROM ez_product WHERE 1 $moreSQL";
echo $sqlQuery;
This query will display all the records containing in prodname or skuno all the search words...
if you want at least one word:
$moreSQL .= " OR (prodname like '%".mysql_real_escape_string($word)."%' OR skuno LIKE '%".mysql_real_escape_string($word)."%') ";
...
$sqlQuery = "SELECT * FROM ez_product WHERE 0 $moreSQL";
Subject
Views
Written By
Posted
3642
September 03, 2005 01:29AM
1964
September 05, 2005 03:33AM
Re: select query help
2116
September 05, 2005 03:45AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.