Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-05-2010, 01:26 AM   #1
treeleaf20
Member
 
Join Date: Oct 2010
Posts: 68
Default Getting Images from Database

Hello,
I currently have some images on my page that are static. I've never really used Actionscript and PHP so I don't really have a code snippet. Anyway, what I have is about 5 across and 4 rows down. What I would like to do is have that auto populate from images I've got stored on my server. Any help or guidance you could provide me would be great. Thanks in advance!
treeleaf20 is offline   Reply With Quote
Old 10-05-2010, 03:08 AM   #2
treeleaf20
Member
 
Join Date: Oct 2010
Posts: 68
Default

I was able to pull in something from an external PHP site using the following code:
ActionScript Code:
myData = new LoadVars(); myData.onLoad = function() { myText_txt.text = this.mail; }; myData.load("localhost/xampp/site/site_flash/text.php");

This works great if I have static variables. However from my PHP page I will have more then one of the same variable. So for example:

PHP Code:
$qry "Select image from pics";
$result mysql_query($qry);
while(
$resultset mysql_fetch_array($result)){
echo 
$resultset['image'];

This could output 2 images or it could output 10 images. Will Actionscript just keep outputting the same variable multiple times? How can I achieve this?

Thanks in advance!
treeleaf20 is offline   Reply With Quote
Old 10-13-2010, 03:28 AM   #3
rkstar
Registered User
 
Join Date: Oct 2010
Location: toronto
Posts: 25
Default

you could easily use XML to pass the image list back to AS from PHP. in your PHP script, cycle through the result set and use SimpleXML to create some XML to send back to flash:

Code:
<?php
$xml = new SimpleXML("<response/>");

while( $r = mysql_fetch_assoc($result) )
{
    $xml->addChild("image", $r['image']);
}

die($xml->asXML());
?>

now in your AS code, you just have to loop thru the XML.image node and bada bing you have all your image results in a nice little package.
rkstar is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:23 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.