Hi,
I have a mysql table which contains a subscription database. I wish to list, in descending order, the totals of subscribers for each country listed. I use the following code to generate the table rows, but with my test data of three records all for the United Kingdom it gives me an output ($seller_body) of two rows for the table one row with a total of 2 records and one row with a total of one. Whereas I'm expecting a single table row displaying a total figure of 3. Here's the code:
$seller_body = "";
$seller_counter = 0;
$sql = "SELECT country , COUNT(*) AS total FROM sellers GROUP BY country ORDER BY total
DESC";
$result = mysql_query($sql, $db) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$seller_counter % 2 == 0? $bgcolor = "#EEEEFF" : $bgcolor = "#EEEEEE";
$seller_country = $row["country"];
$seller_total = $row["total"];
$seller_body .= "
<tr bgcolor='$bgcolor'>
<td width='79%'>
<font face='Verdana, Arial, Helvetica, sans-serif' color='#000000' size='-1'>
$seller_country
</font>
</td>
<td width='21%' align='center'>
<font face='Verdana, Arial, Helvetica, sans-serif' color='#000000' size='-1'>
$seller_total
</font>
</td>
</tr>
";
$seller_counter++;
}