I updated files in order to cache brands and categories on my site. I just noticed that my brand search is not working and wondered if that has to do with what I did to cache the brands.
brands.php is as follows...
<?php
require("includes/common.php");
$atoz["items"] = array();
if ($_GET["q"])
{
$sql = "SELECT brand FROM `".$config_databaseTablePrefix."brand_cache`";
}
else
{
$sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";
}
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($product["brand"])
{
$item = array();
$item["name"] = $product["brand"];
if ($config_useRewrite)
{
$item["href"] = tapestry_hyphenate($product["brand"])."/";
}
else
{
$item["href"] = "search.php?q=brand:".urlencode($product["brand"]).":";
}
$atoz["items"][] = $item;
}
}
}
$banner["h2"] = "<strong>".translate("Brand")." A-Z</strong>";
require("html/header.php");
require("html/menu.php");
print "<H2>Find and compare products and prices in the UK from these brand names!</H2><table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#FFFFE8'><tr><td width='50%'>";
require("html/brands-searchform.php");
print "</td><td width='50%'> </td></tr></table>" ;
require("html/banner.php");
require("html/atoz.php");
require("html/footer.php");
?>
And the brand search form is simply...
<form name='search' action='<?php print $config_baseHREF ?>brand/'>
<table width="100%" height="34" border="0" cellspacing="0" cellpadding="0">
<tr height="34" bgcolor="#FFFFE8">
<td width="7%"> <input type='text' name='q' size='12' align="absbottom"/></td>
<td width="93%"><input type="image" value="Submit" src="/images/searchukbrands_btn.gif" alt="Find and compare UK Brands" align="absbottom"></td>
</tr>
</table>
</form>
Can you see anything untoward in that, or would the problem be in another file?
Yes that does it, I knew you would be able to see what it was. I have no idea why I missed that bit off, but brand search is working fine now.
Thanks.
Hi Clare,
I notice in your query to handle the brand search (where $_GET["q"] is set), there is not actually any code to make use of the q value. You currently have:
if ($_GET["q"])
{
$sql = "SELECT brand FROM `".$config_databaseTablePrefix."brand_cache`";
}
Did you mean to use something like this:
if ($_GET["q"])
{
$sql = "SELECT brand FROM `".$config_databaseTablePrefix."brand_cache` WHERE brand LIKE '%".database_safe($_GET["q"])."%'";
}
Cheers,
David.