1
i am working on a music playlist code with PHP, so I am putting the command to play the song by the $filename variable:
echo "<br><embed src=\"$folder/$filename\" widht=1 height=50><br>";
But when I run this command, it plays all the songs in the folder and not one by one (neatly) as I would like. How can I do that? Follow the complete codes:
index php.
<?php
header('Content-type: text/html; charset=ISO-8859-1');
echo '<form action="list.php">';
echo "<h4>Write your songs folder</h4><br>";
echo "<h5>(DON'T WRITE A BAR IN THE END OR WRITE ANY SPECIAL CHARACTER)</h5>";
echo '<input type="text" name="folder">';
echo '<input type="submit">';
echo "</form>";
php list.
<?php
header('Content-type: text/html; charset=ISO-8859-1');
$folder = $_GET["folder"];
$files = "{$folder}/".$_GET['/*.*'];
if(isset($_GET['folder']) && file_exists("{$folder}/".$_GET['/*.*'])){
$fold = opendir($folder);
while (false !== ($filename = readdir($fold))) {
if (substr($filename,-4) == ".mp3") {
echo "<br><embed src=\"$folder/$filename\" widht=1 height=50><br>";
}
}
}
But you want me to start playing?
– LocalHost
Instead of directly printing what the "readdir" returns, you should put and sort the contents in an Array in the way you think best. After that, just print.
– mau humor