Topic: Dynamically loading images in Simpleviewer

I have a few image names stored in a database table. I would like to connect to my database, read in the image names and load the images based on where they are stored.

I am using PHP as my server scripting language.

I have changed gallery.xml to gallery.php and I start the script with the following:


       //More code.....

However, whenever I do this, the SimpleViewer player does not seem to load. When I comment out the "require_once" statement, the player appears again.

Could anyone tell me what might be wrong? Thanks all.


Re: Dynamically loading images in Simpleviewer


Re: Dynamically loading images in Simpleviewer

Thank you for the response but I made a careless mistake in referring to the config.php file. The problem has been fixed. If you are still interested in looking at the code, I can post it up.


Re: Dynamically loading images in Simpleviewer


Re: Dynamically loading images in Simpleviewer

Yes that is something I am also looking to do with Simple Gallery Pro.

Re: Dynamically loading images in Simpleviewer


Don't know if you are still around.  If you are still willing I would like to see your php code for getting images from a sql database and calling simpleviewer.

Or if anyone else has this working and is willing to share their code, I for one would be thankful.


Re: Dynamically loading images in Simpleviewer

I have gotten it to work locally using php/mysql on a Mac, but when I upload it to my hosting server, I get the dreaded "gallery not found". Maybe someone can help me out with this as well.

Here is the php that grabs from the database and prints out xml:


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

$host = "localhost"; 
$user = "your_usrname_here"; 
$pass = "your_passsword_here"; 
$database = "your_database_name_here"; 

$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; 


so in your html ad a variable to the swfobject code to find the xmldata like so...

<div id="gallery">Requires Flash</div>
    <script type="text/javascript">    
        var fo = new SWFObject&#40;"viewer.swf", "viewer", "100%", "100%", "8", "#000000"&#41;;
        fo.addVariable&#40;"xmlDataPath", "gallery.php"&#41;;         

It works like a charm on my machine but not on my server. I've tested the php file and it writes the xml perfect. I've checked and safe mode is off and XML parser functions are on, etc. etc.

Anyway, you are welcome to it. Maybe you can solve my problem.

Re: Dynamically loading images in Simpleviewer

Oh wow that's exactly what I was looking for. I just posted a new thread on it, probably should have searched longer.

I'm going to give this a try and see if it will work on my server.