|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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; } |
|
#6
|
|||
|
|||
|
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:
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. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > multiple rows from DB to php to flash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|