Order by count
Posted: Tue Jul 09, 2002 9:41 am
Hi peeps
I have created a referral program and all works fine expect....
I have a page showing recommended sites which displays all sites registered and how many hits they have sent us. The aim is to have these displayed in order by hits desc.
however all of a sudden its all over the shop!
i think the prob is something to do with the order but cant get it right.
I have 6 entries so far and its displaying results in this order
Site name | 4
Site name | 3
Site name |16
Site name | 1
Site name | 1
Site name | 1
its as though its not counting the 6 on the site with 16 hits and listing it as though its 1.
Please can anyone help.
Here is part of the code im using:
<?
echo "<table width=100% border=0>";
echo "<td width=300 valign=top>";
echo "<table width=300 border=0>";
echo "<tr bgcolor=#000099>";
echo "<td width=50 align=\"center\">
<font face=Verdana size=1 color=#FFFFFF><b>Rank</b></font></td>";
echo "<td width=200 align=\"left\"><font face=Verdana size=1 color=#FFFFFF><b>Site Name</b></font></td>";
echo "<td width=50 align=\"center\"><font face=Verdana size=1 color=#FFFFFF><b>Hits</b></font></td>";
echo "</tr>";
$db = mysql_connect("localhost", "root");
if(!$db)
{
echo " An Error has occured. Unable to connect to the database.\n";
exit;
}
$sql = "SELECT site_name,count,site_url,descrip from referrer where site_status ='Live' ORDER by count desc, site_name";
$resultSet=mysql_db_query("mydb",$sql,$db);
$count==0;
if ($resultSet)
{
while ($theresult=mysql_fetch_row($resultSet))
{
$count=$count+1;
echo "<tr bgcolor=#FF6600>";
echo "<td align=\"center\">
<font face=Verdana size=1 color=#000099>$count</font></td>";
echo "<td><font face=Verdana size=1><a href=\"$theresult[2]\" target=\"_blank\"><font color=#FFFFFF>$theresult[0]</font></a></td>";
echo "<td align=\"center\"><font face=Verdana size=1 color=#000099>$theresult[1]</td>";
echo "</tr>";
}
mysql_close();
?>
I have created a referral program and all works fine expect....
I have a page showing recommended sites which displays all sites registered and how many hits they have sent us. The aim is to have these displayed in order by hits desc.
however all of a sudden its all over the shop!
i think the prob is something to do with the order but cant get it right.
I have 6 entries so far and its displaying results in this order
Site name | 4
Site name | 3
Site name |16
Site name | 1
Site name | 1
Site name | 1
its as though its not counting the 6 on the site with 16 hits and listing it as though its 1.
Please can anyone help.
Here is part of the code im using:
<?
echo "<table width=100% border=0>";
echo "<td width=300 valign=top>";
echo "<table width=300 border=0>";
echo "<tr bgcolor=#000099>";
echo "<td width=50 align=\"center\">
<font face=Verdana size=1 color=#FFFFFF><b>Rank</b></font></td>";
echo "<td width=200 align=\"left\"><font face=Verdana size=1 color=#FFFFFF><b>Site Name</b></font></td>";
echo "<td width=50 align=\"center\"><font face=Verdana size=1 color=#FFFFFF><b>Hits</b></font></td>";
echo "</tr>";
$db = mysql_connect("localhost", "root");
if(!$db)
{
echo " An Error has occured. Unable to connect to the database.\n";
exit;
}
$sql = "SELECT site_name,count,site_url,descrip from referrer where site_status ='Live' ORDER by count desc, site_name";
$resultSet=mysql_db_query("mydb",$sql,$db);
$count==0;
if ($resultSet)
{
while ($theresult=mysql_fetch_row($resultSet))
{
$count=$count+1;
echo "<tr bgcolor=#FF6600>";
echo "<td align=\"center\">
<font face=Verdana size=1 color=#000099>$count</font></td>";
echo "<td><font face=Verdana size=1><a href=\"$theresult[2]\" target=\"_blank\"><font color=#FFFFFF>$theresult[0]</font></a></td>";
echo "<td align=\"center\"><font face=Verdana size=1 color=#000099>$theresult[1]</td>";
echo "</tr>";
}
mysql_close();
?>