Example #1
0
function getSupervisorOfCenter()
{
    include "supervisor.php";
    $id = $_REQUEST['id'];
    $obj = new Supervisor();
    if (!$obj->getSupervisorOfCenter($id)) {
        echo '{"result":0,"message": "failed to display"}';
        return;
    }
    //at this point the search has been successful.
    //generate the JSON message to echo to the browser
    $row = $obj->fetch();
    echo '{"result":1,"supervisor":[';
    //start of json object
    while ($row) {
        echo json_encode($row);
        //convert the result array to json object
        $row = $obj->fetch();
        if ($row) {
            echo ",";
            //if there are more rows, add comma
        }
    }
    echo "]}";
}