Hi,
I am building a site that lists the months top50 rated songs.
It is working fine except that I want to have the numbered list go to 50 everytime, and if there are not 50 eligible entries,.I want it to say "pending..."
So if there are only 2 entries so far for the month I want it to look like this:
- Song Title
- Another Song Title
- Pending...
- Pending,..
(through to 50)
- Pending..
- Pending...
Here is my current code:
<?php
$this_month = date('m', strtotime('this month'));
$this_year = date('Y', strtotime('this year'));
$sql5 = "SELECT songid, stitle FROM songs WHERE MONTH(sdate) = '$this_month' AND YEAR(sdate) = '$this_year' AND srating != 'n/a' ORDER BY srating DESC LIMIT 50";
$rs = mysql_query($sql5, $conn);
if(mysql_num_rows($rs)) {
$i = 1;
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) {
$stitle = prepOut($row['stitle']);
$songid = $row['songid'];
$url3 = append_sid("song.php?songid=$songid");
echo "<font color=\"#FFFFFF\">$i.</font><a href=\"$url3\">$stitle</a><br>";
$i++;
}}
?>
I think I need to use some sort of a for($i=1, $i <=50, $i++) loop but I dont know the proper syntax.
Any help would be much appreciated.