I'm not sure if its possible or if there is another way to do this but I've been trying to loop a JavaScript function with PHP.
THis is the Javascrip/PHP Function:
<script type="text/javascript">
<?php
while ($songsFunction = mysql_fetch_array($result3)) {
echo "function ".$songsFunction['songID']."(){";
echo "document.getElementById('ogg').src='';";
echo "document.getElementById('mp3').src='';";
echo "document.getElementById('songName').innerHTML='';";
echo "audio.load();";
echo "playPause();";
}
?>
</script>
I have the songID showing up on the playlist:
<?php while ($haha = mysql_fetch_array($result3)) {
echo '<ul>
<li>
<a href="#" onClick="'.$songFunction['songID'].'();">'.$songFunction['songName'].'</a>
<a href="'.$songFunction['mp3Link'].'"><img src="../images/download.png"></a>
</li>
</ul>';
}
?>
The playlist correctly loops. But when i get the function working, if the songID's match up. The playlist disappears...
Is this the correct way to loop a JavaScript function whilst pulling information through a database with variables?
$songFunction['songID']
is a number, prefix the output with a non-number - function names cannot start with number. – pozs Oct 23 '12 at 13:10