0
I’m trying to make a draw of songs but it always displays the last song registered in the database
$sql = "SELECT nome FROM CadMusicas";
$result = mysql_query($sql, $conecta);
while($consulta = mysql_fetch_array($result)) {
$antigos= array($consulta[nome]);
$numMusicas= sizeof($antigos);
# Primeiro ganhador
$sorteado[1] = $antigos[rand(0,$numMusicas- 1)];
}
echo "<b>Musicas Sorteadas:</b> <br />";
echo "<b>1°</b> - " . $sorteado[1] . "<br />";
"... always displays the last song registered in the database" ... and what is your doubt? what’s the problem? what do you want help?
– Fleuquer Lima