Jump to content

Search system, multiple keywords.


Recommended Posts

alright, just making sure I'm on the right track here:

 

elseif(isset($_GET['search'])){
$search=$_GET['search'];
$keyword=explode(" ",$search);
$keywords=implode(",",$keyword);
$sql10000="SELECT product_id FROM $tbl_name2 WHERE keyword IN($keywords)";
$result10000=mysql($sql10000);
while($row10000=mysql_fetch_array($result10000)){
$product_id3=$row10000['product_id'];
$sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3;
mysql($sql15000);
}
}

Link to comment
Share on other sites

The below is returning:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/zyquo/public_html/ghosthuntersportal.com/pages.php on line 39

 

Line 39 is, while($row10000=mysql_fetch_array($result10000)){

 

elseif(isset($_GET['q'])){
$search=$_GET['q'];
$keyword=explode("+",$search);
$keywords=implode(",",$keyword);
$sql10000="SELECT product_id FROM $tbl_name2 WHERE keyword IN($keywords)";
$result10000=mysql_query($sql10000);
while($row10000=mysql_fetch_array($result10000)){
$product_id3=$row10000['product_id'];
$sql15000="SELECT * FROM $tbl_name WHERE product_id=".$product_id3;
$result15000=mysql_query($sql15000);
while($row15000=mysql_fetch_array($result15000)){
extract($row1500);
$content=$product_id;
}
}
}

Link to comment
Share on other sites

Each keyword is a string so it will need to be surrounded by quotes.

 

$keywords= "'" . implode("','",$keyword) . "'";

 

It's always a good idea (for debugging) to echo your sql queries so you can actually see what they look like. eg;

 

echo $sql10000;

Link to comment
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.