I am making a simple web app, in one part of it, the result of SQL query is to be passed from PHP to JavaScript with AJAX.
This is the SQL Query:
$meta_query = mysql_fetch_row(mysql_query("SELECT * from meta WHERE user_id='$user_id'"));
This is how I pass it to JavaScript var_dump($meta_query);
This is what I am getting at JavaScript (as a string):
array(30) {[0]=>string(1) "3"["id"]=>string(1) "3"[1]=>string(2) "14"["user_id"]=>string(2) "14"[2]=>string(10) "29-06-2014"["date"]=>string(10) "29-06-2014"[3]=>string(1) "0"["present"]=>string(1) "0"[4]=>string(1) "0"["future"]=>string(1) "0"}
How, how do I convert this into a proper JavaScript object so that the output is something like:
{"id":"3","user_id":"14","date":"29-06-2014","Present":0,"Future":0}
How do I convert data from the first format to the second in JavaScript? Or should I do something else entirely in PHP to get the data out in some other format? Or should I convert the data to the required format somehow in PHP?