Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Random show from db from 3 fields


weddingm - 4:54 am on Mar 10, 2011 (gmt 0)


I just can't quite get it working. The following code shows all the songs instead of just 1 ?


$songquery="SELECT * from db WHERE lyrics !='NONE'";
$songqueryresult=mysql_query($songquery);
while($songrowdata=mysql_fetch_array($songqueryresult))
{ $song=$songrowdata['song'];
$artist=$songrowdata['artist'];
$lyrics=$songrowdata['lyrics'];

$songs[]="".$song."<br />".$artist."<br /><a href='http://www.sample.com/".$lyrics."'>Lyrics</a>";

srand((double) microtime() * 1000000);
$randomsong=rand(0, (count($songs)-1));

echo "<p>".$songs[$randomsong]."</p>";
}


Thread source:: http://www.webmasterworld.com/php/4278994.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com