الجمعة، 20 ديسمبر 2013

mysql query and encoding it in json format

I'm using this simple php code to encode the MySql query result in json format. But Don't know why it is not giving me the desirable output. I'm actually trying to get the employee details by entering their 'employee_number'.

0) { $result = mysql_fetch_array($result); echo("Success !! Yoo"); $employee = array(); $employee["employee_number"] = $result["employee_number"]; $employee["employee_name"] = $result["employee_name"]; $employee["flag"]=$result["flag"]; // success $response["success"] = 1; // user node $response["employee"] = array(); array_push($response["employee"], $employee); // echoing JSON response echo json_encode($response); } else { // no employee found $response["success"] = 0; $response["message"] = "No employee found"; // echo no users JSON echo json_encode($response); } }else { // no employee found $response["success"] = 0; $response["message"] = "No employee found"; // echo no users JSON echo json_encode($response);}/*} else {// required field is missing$response["success"] = 0;$response["message"] = "Required field(s) is missing";*/// echoing JSON responseecho json_encode($response);?>

View the original article here

ليست هناك تعليقات:

إرسال تعليق