Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe it would be better to use an array to stock your results and encode your array to json and parse it in as3.<br/><br/>Ex:</p> <pre><code>$result = mysqli_query($con,$sql); // create your output array $output = array(); // fetch your results while( $row = mysqli_fetch_assoc($result) !== false ) { // add result row to your output's next index $output[] = $row; } // echo the json encoded object echo json_encode( $output ); </code></pre> <p>In your AS3 code you can get the object from the json string like this:</p> <pre><code>// retrieve data from php call var resultString:String = yourLoader.data; // parse result string as json object var resultObject:Object = JSON.parse( resultString ); </code></pre> <p>In this case your resultObject should be an array containing all your rows.</p> <pre><code>// retrieve data from php call var resultString :String = yourLoader.data; // parse result string as json object and cast it to array var resultArray :Array = JSON.parse( resultString ) as Array; // get the length of the result set var len:int = resultArray.length; // loop the result array for( var i:int = 0; i&lt;len; ++i ) { // trace nobed value trace( resultArray[i].nobed ); } </code></pre> <p>[EDIT]<br/> If you want to name each array part you can do this:<br/><br/> PHP:</p> <pre><code>$result = mysqli_query($con,$sql); // create your outputs array $nobed = array(); $zip = array(); $Location1 = array(); $price1 = array(); // create all you want // fetch your results while( $row = mysqli_fetch_assoc($result) !== false ) { // add result row to your output's next index $nobed[] = $row['nobed']; $zip[] = $row['zip']; $Location1[] = $row ['Location']; // you forgot the [] here meaning add to the end of the array $price1[] = $row ['price']; // you forgot the [] here meaning add to the end of the array //... } // echo the json encoded object echo json_encode( array('nobed'=&gt;$nobed, 'zip'=&gt;$zip, 'Location'=&gt;$Location1, 'price'=&gt;$price1) ); </code></pre> <p>AS3:</p> <pre><code>function Asandler(event:Event):void { // trace your recived data so you can see it before any parsing error trace( event.target.data ); var resultString :String = event.target.data; // parse result string as json object var resultObject :Object = JSON.parse( resultString ); // loop all keys in the object for( var s:String in resultObject ) { // you cannot do this as nobed and Location object don't exists i think, you can trace string or properties maybe trace( 'nobed', resultObject[s] ) but as s is not nobed all the time it's not correct //trace( nobed, resultObject[s] ); //trace( Location, resultObject[s] ); // so maybe add a switch case to make specific operation in function of the key // with switch case you can make a specific code block for a specific value of the variable passed in the switch switch(s) { // if( s == 'nobed' ) case 'nobed' trace( 'nobed', resultObject[s] ); // do what you want with your nobed array break; // if( s == 'zip' ) case 'zip' trace( 'zip', resultObject[s] ); // do what you want with your zip array break; // if( s == 'Location' ) case 'Location' trace( 'Location', resultObject[s] ); // do what you want with your Location array break; // if( s == 'price' ) case 'price' trace( 'price', resultObject[s] ); // do what you want with your price array break; } } } </code></pre> <p>try with a simple php script like this:</p> <pre><code>&lt;?php $row = array(); for( $i=0; $i&lt;10; $i++ ) { $row[] = array('nobed'=&gt;'nobed'.$i, 'zip'=&gt;$i, 'Location'=&gt;$i, 'price'=&gt;$i); } // create your output array $nobed1 = array(); $zip1 = array(); $Location1 = array(); $price1 = array(); // fetch your results for( $i=0; $i&lt;10; $i++ ) { // add result to your output next index $nobed[] = $row[$i]['nobed']; $zip[] = $row[$i]['zip']; $Location1[] = $row ['Location']; // you forgot the [] here meaning add to the end of the array $price1[] = $row ['price']; // you forgot the [] here meaning add to the end of the array } echo json_encode( array('nobed'=&gt;$nobed, 'zip'=&gt;$zip,'Location'=&gt;$Location1,'price'=&gt;$price1) ); ?&gt; </code></pre> <p>I think you have a server configuration problem</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload