I have code written to generate xml data in PHP from my MySQL database. I can display this in my browser using "echo" but wbat I really want is to write this xml data to a seperate xml file so that I can have flash use it.
Here is my code:
[PHP]<?php require_once('C onnections/PhotoABC.php'); ?>
<?php
if (!isset($_SESSI ON)) {
session_start() ;
}
$sqluserid = "SELECT `user_id` FROM `user` WHERE `username` = '".$_SESSION['MM_Username']."'";
$useridqueryres ult = mysql_query($sq luserid)
or die (mysql_error()) ;
if (mysql_num_rows ($useridqueryre sult) > 0) {
$row=mysql_fetc h_assoc($userid queryresult);
$userid=$row['user_id'];
}
$sqlimagename = "SELECT `image_name` FROM `gallery` WHERE `user_id` = '$userid'";
$imagenamequery result = mysql_query($sq limagename)
or die (mysql_error()) ;
$xml_output = "<?xml version=\"1.0\" ?>\n";
$xml_output .= "<images>\n ";
for($x = 0 ; $x < mysql_num_rows( $imagenamequery result) ; $x++){
$row = mysql_fetch_ass oc($imagenamequ eryresult);
$xml_output .= "\t<image>\ n";
xml_output .= "\t\t<image >" . $row['image_name'] . "</image>\n";
$xml_output .= "\t</image>\n";
}
$xml_output .= "</images>";
echo $xml_output;
?>[/PHP]
I would like to write this xml data to a new xml file called "images" and to save it to this directory
"C:\htdocs\Phot oABC\upload_tes t\Jordan"
Any help would be great :)
Here is my code:
[PHP]<?php require_once('C onnections/PhotoABC.php'); ?>
<?php
if (!isset($_SESSI ON)) {
session_start() ;
}
$sqluserid = "SELECT `user_id` FROM `user` WHERE `username` = '".$_SESSION['MM_Username']."'";
$useridqueryres ult = mysql_query($sq luserid)
or die (mysql_error()) ;
if (mysql_num_rows ($useridqueryre sult) > 0) {
$row=mysql_fetc h_assoc($userid queryresult);
$userid=$row['user_id'];
}
$sqlimagename = "SELECT `image_name` FROM `gallery` WHERE `user_id` = '$userid'";
$imagenamequery result = mysql_query($sq limagename)
or die (mysql_error()) ;
$xml_output = "<?xml version=\"1.0\" ?>\n";
$xml_output .= "<images>\n ";
for($x = 0 ; $x < mysql_num_rows( $imagenamequery result) ; $x++){
$row = mysql_fetch_ass oc($imagenamequ eryresult);
$xml_output .= "\t<image>\ n";
xml_output .= "\t\t<image >" . $row['image_name'] . "</image>\n";
$xml_output .= "\t</image>\n";
}
$xml_output .= "</images>";
echo $xml_output;
?>[/PHP]
I would like to write this xml data to a new xml file called "images" and to save it to this directory
"C:\htdocs\Phot oABC\upload_tes t\Jordan"
Any help would be great :)
Comment