spanster90 Posted September 28, 2011 Share Posted September 28, 2011 Consider the following code; <div class="blockrow"> <table cellpadding="10" align="center" border="0"> <tr> <td> <center> <font size=6>Donation Hall of Fame</font><br><br> <font size=2><b>Anonymous Donations are not Counted</b></font><br><br> <font size=3><a href="/donate">Get on This List</a></font> <br> <br> <?php //database connection $connectdb = mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("thatsact_donations"); //query setup $sql = "SELECT * FROM totals ORDER BY donation_total DESC LIMIT 100"; $result = mysql_query($sql) or die(mysql_error()); //initialize container $container = array(); //get entries from db while ($get = mysql_fetch_assoc($result)){ if(!$get[userid]=="0") { $username = "<b><a style=\"color:#00CC00\" href=/member.php/$get[userid]>$get[username]</a></b> donated <b>$$get[donation_total]</b> total so far!"; } $container[] = "<font size=3>$username</font>"; } //combine collected entries $output = implode("<br /><hr>",$container); //print echo $output; mysql_close($connectdb); ?> </center> </td> </tr> </table> </div> I would like to add a rank number to the container starting with one and going 23456 as each piece is echoed. How might I do this because I am very new to php. Example: 1. Username donated $5...... 2. Username donated $4........ 3. Username donated $3....... Thanks in advance. Quote Link to comment Share on other sites More sharing options...
TOA Posted September 28, 2011 Share Posted September 28, 2011 You just want your results numbered? You could use a variable to increment with every loop, or use an <ol> tag Quote Link to comment Share on other sites More sharing options...
spinner0205 Posted September 29, 2011 Share Posted September 29, 2011 Hmmm the ordered list option doesn't seem to work. It doesn't show anything. This is what I am trying; while ($get = mysql_fetch_assoc($result)){ if(!$get[userid]=="0") { $username = "<ol><li><b><a style=\"color:#00CC00\" href=/member.php/$get[userid]>$get[username]</a></b> donated <b>$$get[donation_total]</b> total so far!</li></ol>"; } $container[] = "<font size=3>$username</font>"; } Quote Link to comment Share on other sites More sharing options...
Buddski Posted September 29, 2011 Share Posted September 29, 2011 What he means is to wrap your output in an OL tag, something like this.. $output = '<ol><li>'.implode("</li><li>",$container).'</li></ol>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.