'Filtering PHP to search Key and Value
i have a problem here, im trying to search some value from the key but it keep showing all array (example : i want to search satuan = FLS, but it keep showing all data array, not showing the data that i search)
this is the code
//connection
include 'koneksi.php';
//Parameter
$param=$_GET['param'];
$v=$_GET['v'];
//SQL
if($param=='')
{
$sql="select * from obat";
}else if($param<>'')
{
$sql="select * from obat where $param like '%$v%'";
}
$query=mysqli_query($con,$sql);
$res['obat']=array();
while($data=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
$ft['kode']=$data['kode'];
$ft['obat']=$data['obat'];
$ft['produsen']=$data['produsen'];
$ft['satuan']=$data['satuan'];
$ft['harga']=$data['harga'];
array_push($res["obat"],$ft);
}
echo json_encode($res);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
