I have a question regarding Classifieds 2 script from prozilla.
I added this lines of code inside the search.php file
if($a1[CategoryID] == '43')
{
$TopListings .= "test";
}
Its working ok but if i have 6 classified listings in that category,then the "test" message will appear 6 times.
If i have 30 listings then the "test" message will appear 30 times and so goes on ...
Can you help me with this? I want only to appears once.
This is the search.php file :
PHP Code:
<?
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.ProductName asc ";
}
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.ProductName asc ";
}
$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";
}
if($a1[CategoryID] == '43')
{
$TopListings .= "test";
}
$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");
}
?>
|