Jump to content

Automatically update xml playlist


twinrecords

Recommended Posts

I am building a music community website where visitors can sign up, upload pics and mp3 files, I'm almost finished, the last thing I have to do is get the xml playlist working for each individual member, here's what I need help with.

 

I would like the xml to be populated with a call to the database where the xml tag info will be stored, but I would like the xml to update everytime the member uploads a new mp3 and the flash player is initialized. So each member will have their own xml file in their own folder with the mp3 files.

 

the table in the DB contains these rows, mp3_id(int, auto increment, primary), username, mp3_title, mp3_url, mp3_date.

 

now obviously the date doesn't need to be displayed in the flash player, just internal, but I guess the username, mp3_title and mp3_url needs to be inserted into the xml when the player is started.

 

I have tried 3 different DOM scripts, modified them to suit my setup and I can't get them working, maybe I am inserting it into the wrong place in the php, I have it in the parsing area for the mp3 uploads. here's an example of what the xml would look like:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<XML>

<playlist>
    <song>
        <artist>username</artist>
        <title>mp3_title</title>
        <url>mp3_url</url>
    </song>

 

and here is the final thing I am stumped about, everytime an mp3 is uploaded, the mp3_id will be ascending no matter which member upoloads, so John uploads 5 for his page, numbered 1-5, then tom will upload 3 for his page, they r numbered 6-8, so how would I show the proper increment values in each individual xml file per member.

 

Link to comment
https://forums.phpfreaks.com/topic/238387-automatically-update-xml-playlist/
Share on other sites

Via PHP you plug this into a file..

<?php header ("Content-Type:text/xml"); ?>
//mysql connection info
//mysql query to loop through your DB building out the 

echo '<?xml version="1.0" encoding="UTF-8"?><XML><playlist>';

//while or for or foreach loop you can construct your "XML" output with
while ($mysqlResult, mysql_results_array){
echo'   <song>
        <artist>'.$mysqlResult[username'].'</artist>
        <title>'.$mysqlResult[mp3_title'].'</title>
        <url>'.$mysqlResult[mp3_url'].'</url>
    </song>';
}
echo '</playlist>';

 

i should mention this is not a working example by any means, just a logical example concept. Putting the header at the top of the file will tell a browser/reader that the file is an XML file kinda like tricking it in to thinking that its not really a php file. Of course its also worth mentioning this concept can be elaborated on heavily.

 

Archived

This topic is now archived and is closed to further replies.

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