Jump to content

Jukebox using php


ilikephp

Recommended Posts

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.