ducktape
February 3rd, 2003, 22:07
ok i am setting up a stats program and im a really newbie to php and mysql and I want the highest number to be first on the list. so i have 1 person with 1500 and a person with 750 and the 750 comes first because the 7 is larger unless i enter it to the db as 0750 and then it prints on the page as 0750 which i dont like how can i fix this??? how could i correct the script so that 750 will appear lower on the list than 1500 without adding a leading 0 to it
<?
$db = mysql_connect("localhost", "xxxxxx", "xxxxxx");
mysql_select_db("xxxxxx",$db);
$find_standings = mysql_query("SELECT * FROM ndra WHERE class = 1 ORDER BY points DESC",$db);
$ndra = mysql_fetch_array($find_standings);
echo "<table width=\"50%\" cellpadding=\"2\" cellspacing=\"0\" class=\"table\" style='border:1px solid #CCCCCC' class='main'>
<tr>
<td colspan=\"2\" align=\"left\" bgcolor=\"#003399\"><font color=\"#FFFFFF\"> NOPI.com Pro Import</font>
<tr bgcolor=\"#cccccc\">
<td valign=\"top\" align=\"left\" width=\"75%\" style='border-bottom:1px solid #003399'> Name</td>
<td valign=\"top\" align=\"center\" width=\"25%\" style='border-bottom:1px solid #003399'>Points</td></tr>"; // Top header of table
// This prints out a row for each member
do {
$firstname = ($ndra["first_name"]);
$lastname = ($ndra["last_name"]);
$points = ($ndra["points"]);
if ($x == "1") {
echo "<tr bgcolor=\"#ffffff\">";
$x = "2";
} else {
echo "<tr bgcolor=\"#eeeeee\">";
$x = "1";
}
echo "
<td valign=\"top\" align=\"left\" width=\"75%\"> $firstname $lastname</td>
<td valign=\"top\" align=\"center\" width=\"25%\">$points</td></tr>";
} while ($ndra = mysql_fetch_array($find_standings));
echo "</table>";
?>
TIA
<?
$db = mysql_connect("localhost", "xxxxxx", "xxxxxx");
mysql_select_db("xxxxxx",$db);
$find_standings = mysql_query("SELECT * FROM ndra WHERE class = 1 ORDER BY points DESC",$db);
$ndra = mysql_fetch_array($find_standings);
echo "<table width=\"50%\" cellpadding=\"2\" cellspacing=\"0\" class=\"table\" style='border:1px solid #CCCCCC' class='main'>
<tr>
<td colspan=\"2\" align=\"left\" bgcolor=\"#003399\"><font color=\"#FFFFFF\"> NOPI.com Pro Import</font>
<tr bgcolor=\"#cccccc\">
<td valign=\"top\" align=\"left\" width=\"75%\" style='border-bottom:1px solid #003399'> Name</td>
<td valign=\"top\" align=\"center\" width=\"25%\" style='border-bottom:1px solid #003399'>Points</td></tr>"; // Top header of table
// This prints out a row for each member
do {
$firstname = ($ndra["first_name"]);
$lastname = ($ndra["last_name"]);
$points = ($ndra["points"]);
if ($x == "1") {
echo "<tr bgcolor=\"#ffffff\">";
$x = "2";
} else {
echo "<tr bgcolor=\"#eeeeee\">";
$x = "1";
}
echo "
<td valign=\"top\" align=\"left\" width=\"75%\"> $firstname $lastname</td>
<td valign=\"top\" align=\"center\" width=\"25%\">$points</td></tr>";
} while ($ndra = mysql_fetch_array($find_standings));
echo "</table>";
?>
TIA