ilikephp Posted July 20, 2009 Share Posted July 20, 2009 hi, I am trying to create a jukebox for my website, I have over 300 songs, how can I add all the songs directly to the database instead of entering the name of each song. So I will add a script to my php files that lists all the songs in my database. Thanks... Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 20, 2009 Share Posted July 20, 2009 You could import from a CSV file. You will need all song names, filenames in some format. Quote Link to comment Share on other sites More sharing options...
ilikephp Posted July 20, 2009 Author Share Posted July 20, 2009 thx a lot for your help! for example the Adromeda software directly when it recognizes the folder, it directly add all the songs in a list. so there is no way unless I type them manually? Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 20, 2009 Share Posted July 20, 2009 glob() ID3 Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 20, 2009 Share Posted July 20, 2009 Didn't know there was an extension for ID3! nice. Read the files in your directory using php's filesystem functions and use the ID3 extension to get the songnames from the mp3's. Store the filenames/song names in your db. Quote Link to comment Share on other sites More sharing options...
ilikephp Posted July 20, 2009 Author Share Posted July 20, 2009 I am reading the example, but if u dont mind can u give me a short example? Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 20, 2009 Share Posted July 20, 2009 Something along the lines of <?php $path = "/path/to/mp3/folder/"; $dir = dir($path); while(false !== ($file = $dir->read())) { if(!is_dir($path.$file)) { // read the file if an mp3 if(strstr($file, ".mp3")) { $info = id3_get_tag($path.$file); /* will return the following Array ( [title] => DN-38416 [artist] => Re:\Legion [album] => Reflections [year] => 2004 [genre] => 19 ) */ // store the file in the database mysql_query("INSERT INTO table SET filename='".mysql_real_escape_string($file)."', title='".mysql_real_escape_string($info['title'])."', album='".mysql_real_escape_string($info['album'])."'"); } } } $dir->close(); ?> Dont forget to install the extension first Quote Link to comment Share on other sites More sharing options...
ilikephp Posted July 21, 2009 Author Share Posted July 21, 2009 Do you know any tutorial about installing extensions plz? I tried to download them but I did not know where to put them Thanks... Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 21, 2009 Share Posted July 21, 2009 Are you running linux? Quote Link to comment Share on other sites More sharing options...
ilikephp Posted July 24, 2009 Author Share Posted July 24, 2009 I am running Windows Vista Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted July 26, 2009 Share Posted July 26, 2009 http://i.justrealized.com/2008/10/14/how-to-install-pear-modules-using-xampp/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.