How To Convert Fetch Data Into JSON Format In PHP
<?php
include("connect.php");
$result=mysql_query("select * from tent_house ") or die(mysql_error());
$response["data"]=array();
$st = array();
$row=mysql_num_rows($result);
if($row>0)
{
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$st = $row;
array_push($response["data"],$st);
}
$response["success"]=1;
echo json_encode($response);
}
else
{
$response["success"]=0;
echo json_encode($response);
}
?>
include("connect.php");
$result=mysql_query("select * from tent_house ") or die(mysql_error());
$response["data"]=array();
$st = array();
$row=mysql_num_rows($result);
if($row>0)
{
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$st = $row;
array_push($response["data"],$st);
}
$response["success"]=1;
echo json_encode($response);
}
else
{
$response["success"]=0;
echo json_encode($response);
}
?>
No comments :
Post a Comment