Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Classifieds script help
Old 09-07-2005, 04:54 AM Classifieds script help
Junior Talker

Posts: 1
Trades: 0
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");
}

?>
kattos is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-07-2005, 12:42 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
I had the same type of problem with a calendar i made. Try making a loop that like

while($temp<1)
{
echo "test";
$temp++
}

then once you have gone through the loop once it should stop it from printing test over and over
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Classifieds script help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09684 seconds with 12 queries