<?php
$link = mysql_connect('localhost', 'root', 'admin')
or die('There was a problem connecting to the database.');
mysql_select_db('hospitalmaster');
$hnum = (int)$_POST["hnum"];
$sql = "SELECT d.doctorid, d.doctorname
from hospitalmaster.doctor_master d
inner join pharmacymaster.pharbill e
where e.hnum = '$hnum'
and e.presid = d.d_empno
group by e.presid";
$result = mysql_query($sql);
$response = array();
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$response = $row;
}
echo json_encode(array("Doctor"=>$response));
} else {
echo ("no DATA");
}
?>
i have the api shown above, but this api is returning me as json objects not an json array? i would like to know how to get dotorid an doctorname as a array, since i have many doctor names and id, i want each doctor and their corresponding id as an idividual array, right now they are returning as individual objects. Since this is my first time writing an api, i dont know how to modify the code.