I have the following query string:
index.php?searchwords=searchword&category=7
I'm attempting to get the values from the string and use it in my search query by name.
When I type in a keyword to search, i.e 'searchword', it doesn't return anything even though the Name of the product is 'searchword' and is in the category I've selected. Any thoughts?
elseif(isset($_GET['searchwords'])){
$query2 = "SELECT name from categories where id='$_GET[category]'";
$res=mysql_query($query2) or die("SQL: $query<br />\nError: ".mysql_error());
$row=mysql_fetch_array($res);
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr><td class=\"title1\">";
echo "Category: <b>$row[name]</b>";
echo "</td></tr></table>";
$queryn = "SELECT * from products where category = '$_GET[category]' AND MATCH (name) AGAINST ('$_GET[searchwords]')";
$res=mysql_query($queryn) or die("SQL: $query<br />\nError: ".mysql_error());
$num_rows = mysql_num_rows($res);
if (($num_rows) == 0) {
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr class=\"cells\"><td class=\"body1\" colspan=\"6\"><font color=red>No templates found. Please select another search criteria.</font></td></tr></table>";
} else {
while ($rowp=mysql_fetch_array($queryn)){
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr><td class=\"body1\" width=\"1%\"><a href='index.php?product=$rowp[id]'><img src='images/thumbs/$rowp[photo]' border=0></a></td><td class=\"body1\" valign=\"top\"><p class=\"cartheader\">Template Name: <b>$rowp[name]</b></p>
<p>$rowp[description]</p>
<p><strong>Price: <b><font color=red>$rowp[price]</font></b> | <a href='catalog.php?product=$rowp[id]'>Add to Cart</a> | <a href='images/$rowp[photo]' target='_blank'>Enlarge Image</a></strong></p></td>
</tr>
</table>
<hr size=\"1\">";
}
}
}