PHP and XML and a MYSQL DB

Discussion in 'PHP' started by tomupton, Oct 12, 2010.

  1. #1
    Hi All,

    Im hoping someone can help me here.

    What im looking at doing is having a flash mp3 player on my website, after looking over numerous flash players ive noticed that about 99% of them use an XML file to store all of the mp3's, cover images etc.

    Im creating a site for a client who wants a mp3 player on their website. The site im developing is going to have a custom built cms which im developing myself.
    The question i have is, can you update an XML file dynamically via a database? If so does anyone know who could do this for me?

    I propose to make a mysql table that stores all of the var's for each mp3 track, i then want the database to link to the xml file being used in the flash player.....

    What would you guys suggest?

    Regards

    Tom
     
    tomupton, Oct 12, 2010 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    ok this is the way you need to do it.

    create a new php file that will create the xml file. But it doesn't create a phsical one but a on-the-fly one.

    Step 1: Send a header that this file is an XML file
    
    <?php 
      header ("content-type: text/xml");
    
    PHP:
    then connect to the db
    
    mysql_connect('server','user','pass');
    mysql_select_db('database');
    
    PHP:
    and then build the xml file by quering the db and looping through the result.

    So if you have to provide the xml file to the players you can provide playlist.php and they will accept it as a header is sent that says that this is a xml file.

    hope this helps
     
    stephan2307, Oct 13, 2010 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    You can store all of the track information in a database instead of xml. You can then easily query the database and generate dynamic xml to feed the player as suggested above. I would make sure to store the track in a directory and not in the database. Store the path to the file in the database but not the file itself.
     
    jestep, Oct 13, 2010 IP
  4. tomupton

    tomupton Active Member

    Messages:
    392
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Thanks for all your replies.

    This is the player ive decided to use - http://www.flashcomponentstemplates.com/freebies.html

    Below ive pasted the XML file that controls the player. Surely if i create a dynamic xml file the settings will need to be included too?

    Ideally i want to keep the settings standalone, and just have the tracks as a dynamic playlist if that makes sense.

    What would you guys suggest?

    Tom

    <?xml version="1.0" encoding="utf-8"?>
    <player>
    
    <settings
    
    defaultVolume = "1"
    autoplay = "true"
    
    mainBackgroundColor = "000000"
    buttonsBackgroundColor = "000000"
    buttonsOutlineColor = "ffffff"
    buttonsIconColor = "8A3090"
    buttonsIconOverColor = "FFFFFF"
    volumeBarColor = "FFFFFF"
    loadBarColor = "8A3090"
    progressBarColor ="00ffff"
    
    spectrumLeftColor = "ffffff"
    spectrumLeftLineColor = "FFFFFF"
    spectrumRightColor = "00ffff"
    spectrumRightLineColor = "00FFFF"
    
    />
    
    <song>
    <title>Madcon - Beggin</title>
    <url>songs/Madcon - Beggin.mp3</url>
    </song>
    
    <song>
    <title>T.I. Ft Justin Timberlake - Dead And Gone</title>
    <url>songs/T.I. Ft Justin Timberlake - Dead And Gone.mp3</url>
    </song>
    
    <song>
    <title>Akon Feat Eminem - Smack That</title>
    <url>songs/Akon Feat Eminem - Smack That.mp3</url>
    </song>
    
    <song>
    <title>Eminem - Bagpipes From Baghdad</title>
    <url>songs/eminem-bagpipes_from_baghdad.mp3</url>
    </song>
    
    </player>
    
    
    PHP:
     
    tomupton, Oct 13, 2010 IP