is it possible to add php array to vars in the swfobject code?
swfobject
Collapse
X
-
Tags: None
-
-
-
as the example shows for json_encode does it have to be on echo or can i assign it to a var then pass it to flash using swfobject?Comment
-
so ok does this look right to you as this is what i have......bear in mind all data is coming from a db
Code:$user="theau10_tawUser"; $pass="auction10"; $data="theau10_resources"; $connection=mysql_connect("localhost" ,"$user", "$pass") or die("Unable to connect!"); @mysql_select_db($data) or die( "Unable to select database"); // Select column 1 from table name where column name = $your_var. $sql = "SELECT * FROM savedTemps WHERE tempID = '{$random_digit}'"; // If mysql_query returns false, we'll die with the error. $res = mysql_query( $sql ) or die( mysql_error ); // If a there is a match if ( mysql_num_rows( $res ) > 0 ) { $row = mysql_fetch_array( $res ); } $myVar = json_encode($row);Comment
-
and then after that i can pass $row into flash with swf object i decode it by doing
#include "json.as"
trace( myVar );
varData = JSON.decode(myV ar)
???Comment
-
hi markus im back with some results.
the json prints out only 1 set of array....i have more than 1 row in my db that has the same tempID but different values for each image and the sql is just collecting the 1st set of values.
i called it like below:
sql is only returning the 1st row?Code:$blank = ""; // Select column 1 from table name where column name = $your_var. $locSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'"; // If mysql_query returns false, we'll die with the error. $locRES = mysql_query( $locSQL ) or die( mysql_error ); // If a there is a match if ( mysql_num_rows( $locRES ) > 0 ) { $locAry = mysql_fetch_array( $locRES ); } else{ echo $blank; } $locVar = json_encode($locAry); // Select column 1 from table name where column name = $your_var. $tmbSQL = "SELECT thumbLoc FROM flashGallery WHERE tempID = '{$random_digit}'"; // If mysql_query returns false, we'll die with the error. $tmbRES = mysql_query( $tmbSQL ) or die( mysql_error ); // If a there is a match if ( mysql_num_rows( $tmbRES ) > 0 ) { $tmbAry = mysql_fetch_array( $tmbRES ); } else{ echo $blank; } $tmbVar = json_encode($tmbAry); // Select column 1 from table name where column name = $your_var. $capSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'"; // If mysql_query returns false, we'll die with the error. $capRES = mysql_query( $capSQL ) or die( mysql_error ); // If a there is a match if ( mysql_num_rows( $capRES ) > 0 ) { $capAry = mysql_fetch_array( $capRES ); } else{ echo $blank; } $capVar = json_encode($capAry); mysql_close(); $flashVar1 = 'so.addParam("locVar", "'.$locVar .'");'; $flashVar2 = 'so.addParam("tmbVar", "'.$tmbVar .'");'; $flashVar3 = 'so.addParam("capVar", "'.$capVar .'");';Comment
-
i've decided to json_encode the necessary details before saving it to a db. im having trouble retrieving all data needed into an array as everything i have tried either shows the 1st or last row that is retrieved instead of all rowsComment
-
ive fixed it here is the solution
Code:// Select column 1 from table name where column name = $your_var. $locSQL = "SELECT imageLoc, thumbLoc, imageCap FROM flashGallery WHERE tempID = '{$random_digit}'"; // If mysql_query returns false, we'll die with the error. $locRES = mysql_query( $locSQL ) or die( mysql_error ); // If a there is a match if ( mysql_num_rows( $locRES ) > 0 ) { while($row = mysql_fetch_array($locRES,MYSQL_ASSOC)){ $aryA[]=$row['imageLoc']; $aryB[]=$row['thumbLoc']; $aryC[]=$row['imageCap']; } } $locAry = implode($aryA); $tmbAry = implode($aryB); $capAry = implode($aryC); $flash02="so.addVariable('locVar', '$locAry'); so.addVariable('tmbVar', '$tmbAry'); so.addVariable('capVar', '$capAry');"; mysql_close(); ?>Comment
Comment