function validateservice() { require_once "service.php"; $email = $_REQUEST['email']; $password = $_REQUEST['password']; $obj = new service(); if ($obj->validateservice($email, $password) && $obj->get_num_rows() > 0) { $row = $obj->fetch(); echo '{"result":1,"serviceprovider":['; while ($row) { echo json_encode($row); $row = $obj->fetch(); if ($row) { echo ","; } } echo "]}"; } else { echo '{"result":0,"message:"error getting service provider"}'; } }