New to php. I am trying to send JSON data to front end in name-value pair. I tried an example which I got here The following is my code fragment which sends the data in JSO
try creating an array of objects
$list = array(); while($stmt->fetch()) { // create an object $datum=new stdClass(); $datum->id=$fid; $datum->name=$fname; $list[] = $datum; } $stmt->free_result(); $stmt->close(); echo json_encode($list);