I have a while loop that creates an array prior to json encoding the data but although i have tested it and i get 2 rows returned and it loops twice..my json encode only shows one of the rows of data =/
This is my php:
$get = mysql_query("SELECT * FROM
player t1 INNER JOIN game t2
ON t1.sid=t2.id
WHERE uid='1'") or die(mysql_error());
while($row = mysql_fetch_assoc($get)){
echo 'looped<br/>'; //testing row count
$data[$row['x']] = Array();
$data[$row['x']][$row['y']][0] = $row['bid'];
$data[$row['x']][$row['y']][1] = $row['sid'];
$data[$row['x']][$row['y']][2] = $row['width'];
$data[$row['x']][$row['y']][3] = $row['height'];
$data[$row['x']][$row['y']][4] = $row['offsetx'];
$data[$row['x']][$row['y']][5] = $row['offsety'];
}
$data1 = json_encode($data);
I had 2 loops in total but only one data set for my json which is confusing me:
{"10":{"11":["1","22","1","1","0","0"]}}
Its missing the first row of data which would of created this aswell as the one above:
{"10":{"10":["1","7","2","2","0","32"]}};
I’m wondering if im overwriting some how ? I thought it would not given im assign to arrays and their X:Y are different.
You should only set it if it doesn’t exist yet: