I'm currently saving $row 'id'
from my database into an array. This array is then sent using json_encode
back to my JS file, where I access it. This is working fine.
My issue is that I'm struggling to figure out how to add $row['vote_fb_name']
(string) to the same json callback array (in this case my callback is saved into $feedback
)? $row['vote_fb_uid']
and $row['vote_fb_name']
appear in the same record.
My PHP - here I save my id's into the array:
while ($row = mysql_fetch_assoc($res))
{
$savedResultsInNewArray[] = $row['vote_fb_uid'];
}
$feedback = $savedResultsInNewArray;
I then do my callback which is received by my js file:
echo json_encode(array('returned_val' => $feedback));
In my JS I then run a for loop
to access the id's:
for( var i = 0; i < data.returned_val.length; i++ ){
var returnedId = data.returned_val[i];
console.log("IDS HERE "+returnedId);
}
In this same for loop
I'm looking to access the associated 'name'.
In PHP I figure I need to save my data as a two dimensional array, but how do I do that and afterwards how do I access it in my JS?