Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Output

Status
Not open for further replies.

ladedardar

Technical User
Jan 12, 2010
2
GB
Hello all,
Wondering if you could help me I am using a flash component which requires me to have the XML used in a strict format like this;

<?xml version="1.0" encoding="utf-8"?>
<photos path="images/">
<photo name="photo1" url="photo1.jpg">This is photo1</photo>
<photos>

I am using PHP to output my mysql results in XML however I want the same format as above and I havent been able to do it here is my code...I thank you in advance for help :D

<?PHP

$link = mysql_connect("****","****","");
mysql_select_db("****");


$query = "SELECT ilink,image_name,description FROM gallery";

$results = mysql_query($query);

echo "<?xml version=\"1.0\"?>\n";

echo "<photos>\n";

while($line = mysql_fetch_array($results)) {
echo "<photo>" . $line["ilink"] . $line["image_name"] . $line["description"] . "</photo> \n";
}

echo "</photos>\n";

mysql_close($link);

?>


 
>echo "<photo>" . $line["ilink"] . $line["image_name"] . $line["description"] . "</photo> \n";

Either this:

[tt]echo "<photo url=\"".$line['ilink']."\" name=\"".$line['image_name']."\">".$line['description']."</photo>\n";[/tt]

or this as an alterntive out of others:

[tt]echo "<photo url=\"$line[ilink]\" name=\"$line[image_name]\">$line[description]</photo>\n";[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top