<?php
/*
* Following code will get single product details
* A product is identified by product id (pid)
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get a product from products table
$result = mysql_query("SELECT * FROM news WHERE Menu = 'FirstPage'");
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["news"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$product = array();
$product["Id"] = $result["Id"];
$product["Menu"] = $result["Menu"];
$product["SubPage"] = $result["SubPage"];
$product["PageName"] = $result["PageName"];
$product["NewsTitle"] = $result["NewsTitle"];
$product["PageContent"] = $result["PageContent"];
$product["Image"] = $result["Image"];
$product["MenuType"] = $result["MenuType"];
$product["Date"] = $result["Date"];
// success
// $response["success"] = 1;
// user node
$response["news"] = array();
array_push($response["news"], $product);
}
// success
// $response["success"] = 1;
// echoing JSON response
echo json_encode($response);
}
?>
JSON Validator Shows
{
"news": [
{
"Id": null,
"Menu": null,
"SubPage": null,
"PageName": null,
"NewsTitle": null,
"PageContent": null,
"Image": null,
"MenuType": null,
"Date": null
}
]
}
I am using this for fetching Bengali news from mysql database and parsing through json script for android. Can you please guide me why i am getting null where my db credential, parameters are completely ok.
Any kind help is appreciated,
Thank in advance Ishtiaque