使用 我有一个名为 但是当我设置我的$查询时: p>
它显示我想要的数据 p>
当使用变量 some.php时出错?id = $ id code> p>
tb_syarat_layanan code>的表。 当我尝试获取JSON时,数组显示没有数据。 p>
<?php
//导入数据库
require_once('koneksi.php');
$ query =“select * from tb_syarat_layanan WHERE id_layan = $ id”;
$ hasil = mysqli_query($ con,$ query);
if if(mysqli_num_rows($ hasil)> 0)
{
$ response = array();
$ response [“data”] = array();
while($ x = mysqli_fetch_array($ hasil))
{
$ h ['id_layan'] = $ X [ “id_layan”];
$ h ['dokumen'] = $ x [“dokumen”];
array_push($ response [“data”],$ h);
}
echo json_encode($ response);
} \ n else
{
$ response [“message”] =“No Data”;
echo json_encode($ response);
}
?>
code> pre> \ n
$ query =“select * from tb_syarat_layanan WHERE id_layan = 1”;
code> pre>
$ id code> <设置$ query时,JSON显示无数据 / p>
div>
Error when using some.php?id=$id
I have table named tb_syarat_layanan
. When I try to get JSON, array it shows no Data.
<?php
//Importing database
require_once('koneksi.php');
$query = "select * from tb_syarat_layanan WHERE id_layan=$id";
$hasil = mysqli_query($con,$query);
if(mysqli_num_rows($hasil) > 0 )
{
$response = array();
$response["data"] = array();
while($x = mysqli_fetch_array($hasil))
{
$h['id_layan'] = $x["id_layan"];
$h['dokumen'] = $x["dokumen"];
array_push($response["data"], $h);
}
echo json_encode($response);
}
else
{
$response["message"] = "No Data";
echo json_encode($response);
}
?>
But when I set my $query like this :
$query = "select * from tb_syarat_layanan WHERE id_layan=1";
it show the data that I want
JSON shows no data when $query is set with variable $id