my first question. Normally just find out for myself but this is has got me beaten.
After an ajax send request, I used this php code to get all the rows and cols from my db:
$sql = "SELECT * FROM categories";
$result=$conn->query($sql);
$arr = $result->fetch_all(MYSQLI_ASSOC);
print_r($arr)
gave me this output:
Array ( [0] => Array ( [cat_id] => 1 [cat_name] => Friends [checkbox] => checked ) [1] => Array ( [cat_id] => 2 [cat_name] => Favourites [checkbox] => checked ) [2] => Array ( [cat_id] => 3 [cat_name] => Drink [checkbox] => checked ) [3] => Array ( [cat_id] => 4 [cat_name] => Food [checkbox] => checked )
<br>
I encoded it using:
echo json_encode($result);
I then got the data into a js variable using:
result = Request.responseText;
var categories = JSON && JSON.parse(result) || $.parseJSON(result);
How do I access the rows of data stored in categories? I can only presume the JSON worked as categories is now a type [Object object] but I dont know how else to check.