I don't know why you want to store the filename in a database to be honnest.. not my problem you would say. lol
I found this nice Mp3 flash player this morning:
http://www.jeroenwijering.com/
and I put a bit of code together which happen to be close to what you need (lucky you!)
<?php
$NBFile=0;
$NBDir=0;
$mp3folder="mp3";
if ($handle = opendir($mp3folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != "..") {
if ( strlen($file) >= 3 ) {
if ( substr($file, strlen($file)-4,1) != "." ) {
$DirArray[] = $file;
$NBDir=$NBDir+1;
} }
}
}
}
closedir($handle);
sort($DirArray);
$NBDir=$NBDir-1;
for ($d=0; $d<=$NBDir; $d++) {
$folder_Name1=$mp3folder."/".$DirArray[$d];
if ($handle = opendir($folder_Name1)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (substr($file, strlen($file)-3, 3)=="mp3" ) {
$FileArray[] = $folder_Name1."/".$file;
$DirArray2[] = $folder_Name1;
$NBFile=$NBFile+1;
}
}
}
}
closedir($handle);
if ($handle = opendir($folder_Name1)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (substr($file, strlen($file)-3, 3)=="MP3" ) {
$FileArray[] = $folder_Name1."/".$file;
$DirArray2[] = $folder_Name1;
$NBFile=$NBFile+1;
}
}
}
}
closedir($handle);
sort($FileArray);
sort($DirArray2);
}
if ($handle = opendir($mp3folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (substr($file, strlen($file)-3, 3)=="mp3" ) {
$FileArray[] = $mp3folder."/".$file;
$DirArray2[] = $mp3folder;
$NBFile=$NBFile+1;
}
}
}
}
closedir($handle);
if ($handle = opendir($mp3folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (substr($file, strlen($file)-3, 3)=="MP3" ) {
$FileArray[] = $mp3folder."/".$file;
$DirArray2[] = $mp3folder;
$NBFile=$NBFile+1;
}
}
}
}
closedir($handle);
$NBFile=$NBFile-1;
$data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"."\n";
$data=$data."<player showDisplay=\"yes\" showPlaylist=\"no\" autoStart=\"yes\">"."\n";
for ($i=0; $i<=$NBFile; $i++) {
$file_Name1=$FileArray[$i];
$file_Name2=$DirArray2[$i];
$file_Title=substr($file_Name1, strlen($file_Name2)+1, strlen($file_Name1)-5-strlen($file_Name2));
$data=$data."<song path=\"".$file_Name1."\" title=\"".$file_Title."\" />"."\n";
}
$data=$data."</player>";
$fp = fopen("mp3player.xml", "w");
fwrite($fp, $data);
fclose($fp);?>
<html>
<head>
<title>JW Flash MP3 Player</title>
</head>
<body bgcolor="#C0C0C0">
<p align="center">
<object type="application/x-shockwave-flash" data="mp3player.swf" width="300" height="300" wmode="transparent">
<param name="movie" value="mp3player.swf" />
<param name="wmode" value="transparent" />
</object>
</p>
<p align="center" style="margin-top: 200; margin-bottom: 0">
<i>Credit to Jeroen Wijering for This MP3
Flashplayer. </i></p>
<p align="center" style="margin-top: 0; margin-bottom: 0"><i>
<a target="_blank" href="http://www.jeroenwijering.com/">
http://www.jeroenwijering.com/</a></i></p>
</body>
</html>
If you still want to place the title / song name in the database, you need to create a database table with a minimum of 3 fields: ID . Name . Title
If you look at the code the file name / directory is in the Array.