I'm obviously over-processing the rows being returned from my query, but I don't really understand PHP resources and row counts and arrays.
This is my database call:
$result=mysql_query($query);
if(mysql_num_rows($result)>0){
header('Content-type: application/json');
$rows = array();
while($r = mysql_fetch_assoc($result)){
$rows[] = array($r);
}
echo json_encode($rows);
};
This is what I'm getting back in my Javascript:
Object {data: Array[23], status: 200, config: Object, statusText: "OK"}
data: Array[23]
0:Array[1] <-- superfluous
0: Object
Name: "foo"
Order: "0"
uID: "1"
1:Array[1] <-- superfluous
0: Object
Name: "bar"
Order: "1"
uID: "2"
...
There's a superfluous array layer in there. It should look like this:
Object {data: Array[23], status: 200, config: Object, statusText: "OK"}
data: Array[23]
0:Object
Name: "foo"
Order: "0"
uID: "1"
1: Object
Name: "bar"
Order: "1"
uID: "2"
...
I'm tempted to remove the rows = array() but I don't know how. I don't get how to turn my db rows into an array properly.