Jump to content

Recommended Posts

Hi all,

 

I think this is what I want to do, however I would like some advice on if this is the correct way of doing things, and HOW to actually do it!

 

Basically I have a webpage which pulls information on a band from a database depending on the user id, which is taken form the address bar.

 

What I want to do is play a song in the background. I am guessing that putting the file in the sql database is a bad idea, so I am assuming that I create a folder on my server to store the files, and then somehow link the files in the mysql database.

 

I am planning on playing them using the html embed tag.

 

the table structure will basically be

 

userid, song_name, mp3_link.

 

Is this the best way to do this do you think?

 

I think that I can select the song from the database and insert it into the embed tag.

 

Any thoughts are code snippets would be great :)

Link to comment
https://forums.phpfreaks.com/topic/153877-playing-music/
Share on other sites

What if  a band had multiple songs?

 

Maybe you should do something like, have a table for bands, and a table for songs. And each song has an ID that relates to their band. Just a suggestion.

 

So, say a band id was 234. You could then do something like:

 

$sql = "SELECT * FROM songs WHERE bandid='234'";

 

to grab all of that band's songs.

Link to comment
https://forums.phpfreaks.com/topic/153877-playing-music/#findComment-808729
Share on other sites

Well if you have your songs in music/BAND_NAME/SONG , you could get them details by storing them in the database. So to get all the songs for a band, something like this:

 

$band = $_GET['band'];
$sql = mysql_query("SELECT * FROM songs WHERE band='$band'");
while($fetch = mysql_fetch_array($sql))
{
$song = $fetch['song'];
echo '<embed src="music/'.$band.'/'.$song.'" />';
}

Link to comment
https://forums.phpfreaks.com/topic/153877-playing-music/#findComment-808898
Share on other sites

As Ive said in previous posts, u should look at the data and how to organize first. jackPf does make a good point in multiple songs for a band.

u can even add genres, and so forth.

 

but first design yer data fields and tables

 

songs table (id, band id,  genre id, title, url)

band table (id, genre, name,)

genre table (id, name)

 

and so forth, by keeping the tables seperate, u will give yerself a bit more fleibility in the future.

 

Link to comment
https://forums.phpfreaks.com/topic/153877-playing-music/#findComment-808902
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.