I want to be able to play all of the audio files in my database via by embedding the source in a player.
I have created an sql query that will return an array containing all of my mp3 names.
I then use a while loop
while($row = mysqli_fetch_array($result)) {
$sourcefile=$row['location'];
echo '<audio controls>';
echo '<source src="$sourcefile" type="audio/mpeg">';
echo "$sourcefile";
echo '</audio>';
}
Which results in the following html:
<audio controls>
<source src="$sourcefile" type"audio/mpeg">
</audio>
If I explicitly substitute the $sourcefile, within the audio tag, with songname.mp3 it works just fine.
And just to make sure the php variable is getting the correct value, I used an echo statement to see the value it contained and it is indeed songname.mp3.
What could possibly be wrong?