Topic: PHP, MySQL and xmlDataPath

I am working on a little php script that prints out xml data for another project. The file is a .php file but actually echoes xml. I was wondering if I could use this same idea to build the xml gallery file with simple viewer? Can I simply make my add variable file look like this and it work?

fo.addVariable("xmlDataPath", "gallerydata.php");

Will flash read the xml that is echoed in the php file or must it have an xml extension? I just thought I would ask if anyone has tested this before I go through the trouble.


Re: PHP, MySQL and xmlDataPath

Yes that will work.

Felix Turner
SimpleViewer Support Team.

Re: PHP, MySQL and xmlDataPath

Awesome. I got it to work. Here is a little script that pulls an array from a mysql database and prints a SimpleViewer gallery xml file. Just add the variable to the html page to point to gallery.php and you are in business.


header&#40;"Content-type&#58; text/xml"&#41;; 

$host = "localhost"; 
$user = "username"; 
$pass = "password"; 
$database = "database_name"; 

$linkID = mysql_connect&#40;$host, $user, $pass&#41; or die&#40;"Could not connect to host."&#41;; 
mysql_select_db&#40;$database, $linkID&#41; or die&#40;"Could not find database."&#41;; 

$query = "SELECT * FROM tablename ORDER BY seq ASC"; 
$resultID = mysql_query&#40;$query, $linkID&#41; or die&#40;"Data not found."&#41;; 

$xml_output = "<?xml version="1.0" encoding="UTF-8" ?>n";
$xml_output .= "<simpleviewerGallery maximageHeight="640" maximageWidth="640" textColor="0xFFFFFF" frameColor="0xffffff" frameWidth="10" navPadding="20" stagePadding="30" thumbnailColumns="3" thumbnailRows="3" navPosition="left" title="" enableRightClickOpen="false" backgroundimagePath="" thumbPath="" imagePath="">n";

for&#40;$x = 0 ; $x < mysql_num_rows&#40;$resultID&#41; ; $x++&#41;&#123; 
$row = mysql_fetch_assoc&#40;$resultID&#41;; 
$xml_output .= "t<image>"; 
$xml_output .= "tt<filename>" . $row&#91;'filename'&#93; . "</filename>"; 
$xml_output .= "t</image>n"; 

$xml_output .= "</simpleviewerGallery>"; 

echo $xml_output; 


The mysql table I used only has three columns: ID, filename, and seq (my own column for keeping order)