Hi, it's me again, lol. I finally have working code for totalling points for my members. IT ACTUALLY WORKS! lol I need to take it one step further and couldn't find what I was looking for with a search here.
I am selecting info from a table, getting a total on one column, then spitting out the results in DESC order on the TOTALS field. Now I need to have a RANK to display in ASC order ie 1, 2, 3, 4 for the rows.
Here is what is working so far, without the HTML and db connect stuff.
$query="SELECT `nick` , SUM( `pointamt` ) AS `TotPoints`
FROM `records`
GROUP BY `nick`
ORDER BY `TotPoints` DESC ";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
//here is where the report header HTML code goes
$i=0;
while ($i < $num)
{
//I want the $rank variable to be first
$nick=mysql_result($result,$i,"nick");
$TotPoints=mysql_result($result,$i,"TotPoints");
echo "<tr>";
//echo "<td align right>$rank</td>";
echo "<td align left>$nick</td>";
echo "<td align=right>$TotPoints</td>";
echo "</tr>";
++$i;
}
I have tried several things and nothing works. I obviously have no clue how to go about this, lol. The results should start with 1 and increment by 1 each time thru the loop just like any count would work, but I am lost on getting it to display. :-(
Any help would be greatly appreicated. If you know of a thread that addresses this, please point me to it. My searches turned up with bogus stuff that I'd have to weed thru for a year, lol.
Thanks again,
Barb