1 Answers
<?php
$row = mysql_query('select * from user');
$data_row = ();//execute the query
$json_data=array();//create the array
foreach($row as $rec)//foreach loop
{
$json_array['id']=$rec['id'];
$json_array['name']=$rec['name'];
$json_array['roll_no']=$rec['roll_no'];
$json_array['degree']=$rec['degree'];
//here pushing the values in to an array
array_push($json_data,$json_array);
}
echo json_encode($json_data);
?>