Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Thanked 0 Times in 0 Posts

    Can you have an XML file created from a database using PHP


    I'm not sure this is possible but i have a flash video jukebox section on my site that has a tileList that is populated by an XML file. I would like to add the information to the XML file through a MySQL database using php if possible.
    Right now i have this code that calls the information in the XML format but how do i get his to save as an XML file?


    //XML output of an existing MySql database
    header("Content-type: text/xml");

    //to create connection to database
    $connection = mysql_connect("localhost","root", "root")
    or die ("could not connect to database");

    //to select the database here
    $db = mysql_select_db("motorsports",$connection)
    or die ("Couldn't select database.");

    $rs = mysql_query("select vid_desc, src, thumb FROM video_blog ORDER BY date_id DESC",$connection)
    or die ("invalid query");

    //count the no. of columns in the table
    $fcount = mysql_num_fields($rs);

    //you can choose any name for the starting tag
    echo ("<playlist>");
    while($row = mysql_fetch_array( $rs ) )

    for($i=0; $i< $fcount; $i++)
    $tag = mysql_field_name( $rs, $i );
    echo ("<$tag>". $row[$i]. "</$tag>");

    echo ("</playlist>");


    Thanks in advance for any help you can give.


  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    Have a look at the SimpleXLMElement class:



    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts