The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> Flash Help
|
multiple rows from DB to php to flash
Discuss multiple rows from DB to php to flash in the Flash Help forum on Dev Shed. multiple rows from DB to php to flash Flash Help forum discussing all products originally created by Macromedia including DreamWeaver, Contribute, Flash, Fireworks, Freehand, Director, Authorware and HomeSite. Adobe bought Macromedia in 2005.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 20th, 2001, 11:54 AM
|
|
Contributing User
|
|
Join Date: Mar 2001
Posts: 46
Time spent in forums: 55 m 18 sec
Reputation Power: 13
|
|
|
multiple rows from DB to php to flash
has anyone here ever had any experience pulling multiple rows from a table in a DB with php and then passing those to a flash file via loadvariables().
i can get one row no problem, but not multiple rows. i've tried just about everything. passing arrays, dynamic variable names... i'm stumped.
|

December 24th, 2001, 05:19 PM
|
|
|
|
I don't see anythign preventing you from sending multiple rows, just number them in some way. Put all the data for the first row in vars like this:
var1_1
var2_1
var3_1
etc.
No reason you can't do that. It's a cheesy workaround but that's Flash for you. You could also try XML but I don't like the way XML is so bulky and not space efficient, and I try to keep my Flash+PHP programs as tight and efficient as possible.
|

December 31st, 2001, 11:45 AM
|
|
Shrill Digital God
|
|
Join Date: Jun 2001
Location: Raleigh, NC
Posts: 64
Time spent in forums: 32 m
Reputation Power: 12
|
|
|
incremented name/value pairs
In PHP:
<?
// Query stuff here
$current_row = 1;
while ($fetch = mysql_fetch_array($result)) { echo "&varName".$current_row."=".$fetch["fieldName"]."";
$current_row++;
}
echo "&loaded=1";
?>
In Flash Actionscript:
count = 0;
index = 1;
loadVariables ("php_template.php", "", "POST");
// Then, with the text field named flashVarName, on a keyframe:
flashVarName = varName1;
// Now make buttons to advance / back up in this fashion:
on (press) {
if (Number(index) < Number(count)) {
index = Number(index)+1;
} else {
index = 1;
}
flashVarName= eval("varName" add index);
}
__________________
I'm not impatient, I just have a low tolerance for boredom.
|

December 31st, 2001, 01:01 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Posts: 46
Time spent in forums: 55 m 18 sec
Reputation Power: 13
|
|
|
thanks very much for the suggestions. i need the rows displayed in flash in a list format. i can pass say the first 20 rows like you guys mentioned and then create 20 different movie clips all with different but corresponding variable names. but how do i stop a longer row from wrapping and then overlapping the following movie clip.
is there a way to dynamically create these movie clips depending on the variables it gets from your php script so i don't have to create 20 movie clips?
-alligator
|

December 31st, 2001, 01:51 PM
|
|
Shrill Digital God
|
|
Join Date: Jun 2001
Location: Raleigh, NC
Posts: 64
Time spent in forums: 32 m
Reputation Power: 12
|
|
|
something like this
This scenario if you have already loaded your incremented name/value pairs (see my previous example):
In Flash Actionscript
// Declare your variables
x = 1;
position = 0;
while (x <= _root.numberRows) {
// "post"+x being each duplicated clip's new name:
duplicateMovieClip ("_root.movieClip", "post"+x, x);
setProperty ("_root.post"+x, _y, position);
this["post"+x].clip1 = _root.["clip1"+x];
position = position+64;
x = x+1;
}
|

December 31st, 2001, 05:15 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Posts: 46
Time spent in forums: 55 m 18 sec
Reputation Power: 13
|
|
okay so first i tried cutting your action script into flash 5 but i got syntax errors i couldn't figure out, and it wouldn't let me switch back to normal mode, so then i tried to break apart your post and recreate my own example. clearly i still don't understand some things.
in php4flash_temp.php:
PHP Code:
<?
include("dbconnect_yank.php");
$query = "select topic from topics order by date desc";
$result = mysql_result($query);
$row = mysql_fetch_row($result);
print "num_rows=" . mysql_num_rows($result);
$x = 1;
while ($row) {
print "value_" . $x . "=" . $row[0];
$x = $x + 1;
$row = mysql_fetch_row($result);
}
print "&loaded=1";
?>
i'm not sure what the variable "&loaded" is supposed to be for yet...
in flash on the main timeline keyframe one there is an instance of a movie clip called "db_text". in it there is a dynamic text field with the variable name "flash_var_name".
also on keyframe one of the main timeline there is the fallowing action script:
count = 1;
position = 0;
loadVariablesNum ("php4flash_temp.php", 0, "POST");
then on keyframe two of the main timeline there is this:
while (count <= num_rows) {
duplicateMovieClip ("db_text", "dup"+count, count);
setProperty ("this.dup"+count, _y, position);
set ("this.dup"+count+".flash_var_name", "value_"+count);
position = position + 64;
count = count + 1;
}
stop ();
am i close???
Last edited by alligatorTim : December 31st, 2001 at 05:18 PM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|