List () function with NULL values
Posted: Tue Mar 04, 2008 9:30 pm
Hello everyone and as usual thank-you in advance for any help and/or suggestions. I'm making a web page for my baseball league and again have come upon a little snag. I'm in the process of making the standings script. The values come from several joined MySQL tables resulting in a two dimensional array. My problem starts when I try to sort the array by the win% column only. I achieve my sort but since there are some NULL values my results are not great. Here is the sample of the code. How do I use the LIST() function with NULL values or is there an easier way. THANKS
Code: Select all
function reverse_compare($x,$y)
{
if ($x[8]==$y[8])//column [8] is winning% in array
return 0;
elseif ($x[8]>$y[8])//x>y gives descending values or x<y for ascending
return -1;
else
return 1;
}
usort ($standings,'reverse_compare');
for ($rows=0;$rows<$num_teams;$rows++)
{
while (list($key,$value)=each ($standings[$rows]))
{
echo "|$value ";
}
echo '|<br />';
}