I'm trying to show an array like this (show id_supplier
and nama_supplier
)
{"1":"PT Kesatu","2":"PT Kedua","3":"PT Ketiga","4":"PT Keempat"}
from supplier
table. I've used the code below:
$query = mysql_query("SELECT id_supplier, nama_supplier FROM supplier ORDER BY nama_supplier");
$supplier = array();
while($row = mysql_fetch_object($query)){
$supplier = $row;
}
echo json_encode($supplier);
but it's just showing me 1 record, and the results are like this
{"id_supplier":"5","nama_supplier":"PT Unggas Makmur"}