I'm attempting to convert my HTML5 script of an mp3 player so that it reads mp3 files from a folder dynamically, instead of me statically typing the file names into the script. I'm still a neophyte when it comes html and php. So, I appreciate any direction given. Here is a snippet of my original code that works flawlessly:
</audio>
<!--Audio in our Playlist-->
<div class="Playlist">
<ul class="playlist">
<li audiourl ="data/Song1.mp3">Song1</li>
<li audiourl ="data/Song2.mp3">Song2</li>
<li audiourl ="data/Song3.mp3">Song3</li>
<li audiourl ="data/Song4.mp3">Song4</li>
<li audiourl ="data/Song5.mp3">Song5</li>
<li audiourl ="data/Song6.mp3">Song6</li>
</ul>
</div>
This is the code that I have attempted, but it does not display the files. If I put the $file variable in between "...>$file<..." it displays the files with the intended style of my css sheet. But, the files will not play when selected. I wouldn't think that I would need to change my Javascript file:
</audio>
<!--Audio in our Playlist-->
<div class="Playlist">
<ul class="playlist">
<?php $files = scandir( "data/" ); ?>
<?php foreach ( $files as $file )
if ( $file != '.' && $file != '..' )
echo "<li audiourl=\"data/$file\"></li>"; ?>
</ul>
</div>
I appreciate any direction....