<?php
include("db_connection.php");
if(isset($_POST['id']) && isset($_POST['id']) != "")
{
// get User ID
$user_id = $_POST['id'];
// Get User Details
$query = "SELECT * FROM products WHERE id = '$user_id'";
if (!$result = mysql_query($query)) {
exit(mysql_error());
}
$response = array();
if(mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$response[] = $row;
}
}
else
{
$response['status'] = 200;
$response['message'] = "Data not found!";
}
// display JSON data
header('Content-type: application/json');
echo json_encode($response); ;
}
else
{
$response['status'] = 200;
$response['message'] = "Invalid Request!";
}
?>
The above code gets a value from the home page.Fetches the row from database and passes the row to home page using json.The echo json_encode($response) is not printing the json value.Is the array assigned to $response? What are the changes i need to make? Help me out!!