I want to search keywords from 2 tables. I have tries some queries but were not working.
I have broken down my keywords into an array as below.
Code: Select all
$keywords = $_GET[q];
$kt=split(" ",$keywords);//Breaking the string to array of words
// Now let us generate the sql
while(list($key,$val)=each($kt)){
if($val<>" " and strlen($val) > 0){$q .= " name like '%$val%' or ";}
}
$q=substr($q,0,(strLen($q)-3));
CARDS TABLE
id name size price
1 Love & Hate A3 50
2 I am in Love A4 80
3 In the Blues A4 80
GIFTS TABLE
id name price
1 cups and spoon 65
2 love mug 33
3 Hi bee 20
Now if I search for "hi love", it should show me
FROM CARDS TABLE
1 Love & Hate A3 50
2 I am in Love A4 80
FROM GIFTS TABLE
2 love mug 33
3 Hi bee 20
pls how do query the tables
Thanks