function getservicelist() { require_once "service.php"; $id = $_REQUEST['serviceid']; $obj = new service(); if ($obj->getservices($id)) { $row = $obj->fetch(); echo '{"result":1,"serviceproviders":['; while ($row) { echo json_encode($row); $row = $obj->fetch(); if ($row) { echo ","; } } echo "]}"; } else { echo '{"result":0,"message:"error getting services"}'; } }