iamali
07-14-2007, 12:09 PM
Hi all,
I'm having a bit of trouble with variables passed from a database into Flash using PHP. This is what I'm working on - http://www.alisongreen.me.uk/majorproject/w4/. What I want eventually is to have photographs uploaded displayed on the walls for the different sections.
I'm working on the 'loading images' section at the moment and so far I have this - http://www.alisongreen.me.uk/test/test2.html which gets the variables from the database using this code:
<?php
$con = mysql_connect("localhost","iamali_w4","excellent");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("iamali_w4", $con);
$result = mysql_query("SELECT * FROM tbl_images");
while($row = mysql_fetch_array($result)) {
$cat = $row['cat'];
$filename = $row['filename'];
$description = $row['description'];
$id = $row['id'];
}
$passIn = "" ;
$passIn .= "&" . "cat=" . $cat . "&" ;
$passIn .= "filename=" . $filename . "&" ;
$passIn .= "description=" . $description . "&" ;
$passIn .= "id=" . $id ;
print $passIn;
mysql_close($con);
?>
and then displays an image and the data in Flash using this actionscript:
myVars = new LoadVars();
myVars.onLoad = function() {
cat.text = this.cat;
filename.text = this.filename;
description.text = this.description;
id.text = this.id;
var filename = (myVars.filename);
createEmptyMovieClip("img", 1);
img._x = 20+count;
img._y = 20+count;
loadMovie("http://www.alisongreen.me.uk/majorproject/w4/present/thumbnails/" +(myVars.filename), _root.img);
}
myVars.load("http://www.alisongreen.me.uk/test/db.php", this, "GET");
At the moment this just displays one image, the last image added to the database. Just wondering has anyone got any idea how to incorporate a loop into this so that I can display all the images in the database on one page, not just the last one? I've looked at duplicateMovieClip and while loops and just got stuck.
Thanks all
I'm having a bit of trouble with variables passed from a database into Flash using PHP. This is what I'm working on - http://www.alisongreen.me.uk/majorproject/w4/. What I want eventually is to have photographs uploaded displayed on the walls for the different sections.
I'm working on the 'loading images' section at the moment and so far I have this - http://www.alisongreen.me.uk/test/test2.html which gets the variables from the database using this code:
<?php
$con = mysql_connect("localhost","iamali_w4","excellent");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("iamali_w4", $con);
$result = mysql_query("SELECT * FROM tbl_images");
while($row = mysql_fetch_array($result)) {
$cat = $row['cat'];
$filename = $row['filename'];
$description = $row['description'];
$id = $row['id'];
}
$passIn = "" ;
$passIn .= "&" . "cat=" . $cat . "&" ;
$passIn .= "filename=" . $filename . "&" ;
$passIn .= "description=" . $description . "&" ;
$passIn .= "id=" . $id ;
print $passIn;
mysql_close($con);
?>
and then displays an image and the data in Flash using this actionscript:
myVars = new LoadVars();
myVars.onLoad = function() {
cat.text = this.cat;
filename.text = this.filename;
description.text = this.description;
id.text = this.id;
var filename = (myVars.filename);
createEmptyMovieClip("img", 1);
img._x = 20+count;
img._y = 20+count;
loadMovie("http://www.alisongreen.me.uk/majorproject/w4/present/thumbnails/" +(myVars.filename), _root.img);
}
myVars.load("http://www.alisongreen.me.uk/test/db.php", this, "GET");
At the moment this just displays one image, the last image added to the database. Just wondering has anyone got any idea how to incorporate a loop into this so that I can display all the images in the database on one page, not just the last one? I've looked at duplicateMovieClip and while loops and just got stuck.
Thanks all