Jump to content


Photo

Search Box Help


  • Please log in to reply
No replies to this topic

#1 daena76

daena76
  • New Members
  • Pip
  • Newbie
  • 8 posts
  • LocationRockville, Maryland USA

Posted 20 June 2006 - 12:57 PM

I have a file "search.php" below that only picks up the search keywords from an item's "description". Some of my members do not repeat the product title/name on the description box as they see it redundant hence name/title is being ignored by the search query. What do I add to the code below so that it searches item titles too. (I have a classified ads site) Thanks :-) Any help is appreciated. ~danes

<?
require_once("conn.php");
require_once("includes.php");

if(!empty($_GET[Start]))
{
$Start = $_GET[Start];
}
else
{
$Start = '0';
}

$ByPage = '20';

if($_GET[what])
{
$query[] = " (class_catalog.Description like '%$_GET[what]%') and (class_catalog.CategoryID = class_categories.CategoryID) ";
}

if(!empty($_GET[c]))
{
$query[] = " class_catalog.CategoryID = class_categories.CategoryID and class_categories.CategoryID = '$_GET[c]' ";
}

if(!empty($_GET[m]))
{
$query[] = " class_catalog.CategoryID = class_categories.CategoryID and class_catalog.MemberID = '$_GET[m]' ";
}

if($_GET[rate] == "latest")
{
$query[] = " class_catalog.CategoryID = class_categories.CategoryID ";
$order[] = " class_catalog.DatePosted desc ";
}

if($_GET[rate] == "top")
{
$query[] = " class_catalog.CategoryID = class_categories.CategoryID ";
$order[] = " class_catalog.views desc ";
}

if(!empty($query))
{
$MyQuery = implode(" and ", $query);
}

if(!empty($order))
{
$MyOrder = implode(" and ", $order);
}
else
{
$MyOrder = " class_catalog.DatePosted desc ";
}

$q1 = " select * from class_catalog, class_categories where $MyQuery order by $MyOrder limit $Start, $ByPage ";

$qnav = " select * from class_catalog, class_categories where $MyQuery ";

$r1 = mysql_query($q1) or die(mysql_error());

if(mysql_num_rows($r1) > '0')
{
$col = "white";
while($a1 = mysql_fetch_array($r1))
{
if($col == "white")
{
$col = "dddddd";
}
else
{
$col = "white";
}

$DatePosted = date('d-M-Y', $a1[DatePosted]);

if(!empty($a1[images]))
{
$image = "Yes";
}
else
{
$image = "No";
}

$SearchRows .= "<tr bgcolor=$col>\n\t<td><a class=BlackLink href=\"info.php?id=$a1[ProductID]\">$a1[ProductName]</a></td>\n\t<td><a class=BlueLink href=\"search.php?c=$a1[CategoryID]\">$a1[CategoryName]</a></td>\n\t<td>$DatePosted</td>\n\t<td>$image</td>\n</tr>\n\n";
}

$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);

if($rows > $ByPage)
{
$Navigation .= "<br><table align=center width=580>";
$Navigation .= "<td align=center><font face=verdana size=2> | ";

$pages = ceil($rows/$ByPage);

for($i = 0; $i <= ($pages); $i++)
{
$PageStart = $ByPage*$i;

$i2 = $i + 1;

if($PageStart == $Start)
{
$links[] = " <span class=RedLink>$i2</span>\n\t ";
}
elseif($PageStart < $rows)
{
$links[] = " <a class=BlackLink href=\"search.php?Start=$PageStart&what=$_GET[what]&c=$_GET[c]&m=$_GET[m]&rate=$_GET[rate]\">$i2</a>\n\t ";
}
}

$links2 = implode(" | ", $links);

$Navigation .= $links2;

$Navigation .= "| </td>";

$Navigation .= "</table><br>\n";

}

require_once("templates/HeaderTemplate.php");
require_once("templates/ResultsTemplate.php");
require_once("templates/FooterTemplate.php");
}
else
{
require_once("templates/HeaderTemplate.php");
require_once("templates/NoResultsTemplate.php");
require_once("templates/FooterTemplate.php");
}


?>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users