Discover Dynamic XML: Flash Photo Gallery PHP Loop Files Tutorial

Discover Dynamic XML: Flash Photo Gallery PHP Loop Files Tutorial

Listening Video


Learn how to render dynamic XML files for Flash(or any other) Photo Gallery applications using PHP loops to show the most current data at all times.
This script would be named something like myXML.php

Learn HTML
<?php// PHP file that renders perfect Dynamic XML for any image applications
// Script written by Adam Khoury @ www.developphp.com - April 05, 2010
// View the video that is tied to this script for maximum understanding
// -------------------------------------------------------------------
header("Content-Type: text/xml"); 
//set the content type to xml
// Initialize the xmlOutput variable
$xmlBody '<?xml version="1.0" encoding="ISO-8859-1"?>'
;$dir "images/gallery1/"// Specify Directory where images are $xmlBody .= "<XML>"// Start XMLBody output
// open specified directory using opendir() the function
$dirHandle opendir($dir
); // Create incremental counter variable if needed$i 0;
while (
$file readdir($dirHandle
)) {
      
// if file is not a folder and if file name contains the string .jpg 
      
if(!is_dir($file) && strpos($file'.jpg'
)){
         
$i++; 
// increment $i by one each pass in the loop
         
$xmlBody .= 
'
<Picture>
    <picNum>' 
$i 
'</picNum>
    <picURL>' 
$dir '' $file 
'</picURL>
</Picture>'
;
      } 
// close the if statement// End while loopclosedir($dirHandle); // close the open directory$xmlBody .= "</XML>";
echo 
$xmlBody
// output the gallery data as XML file for flash?>

0 Response to "Discover Dynamic XML: Flash Photo Gallery PHP Loop Files Tutorial"

Post a Comment