PDA

View Full Version : Trying to use database to populate XML file


debecc
03-12-2010, 09:27 PM
Hi,

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?

<?php



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

Deb

drhowarddrfine
03-13-2010, 03:11 AM
This is a PHP question, not XML.

Alex Vincent
03-13-2010, 04:28 PM
Normally, I'd let it slide, drhoward. If it's XML-related in any way, it's generally welcome here.

However...
http://codingforums.com/showthread.php?t=191380

Cross-posted and CLOSED.

Please don't post the same question twice. It confuses people who are trying to help you and annoys moderators (like me). :)

(That's just my standard don't-do-that line. I'm not really annoyed.)