0
I made a simple request to the database and am trying to pass this data to a json but a part is being duplicated in JSON
PHP:
$query = "SELECT * FROM UNIFORMS";
$result = mysqli_query($connection,$query);
$rows= array();
while($sonuc = mysqli_fetch_assoc($result)) {
$rows[id]=$sonuc[id];
$rows[userid]=$sonuc[userid];
$rows[uniform_type]=$sonuc[uniform_type];
$rows[date]=$sonuc[date];
$rows[size]=$sonuc[model];
$rows[color]=$sonuc[color];
$rows[provider_id]=$sonuc[provider_id];
$rows[contract]=$sonuc[contract];
$rows[amount]=$sonuc[amount];
$rows[cost]=$sonuc[cost];
$rows[place]=$sonuc[place];
array_push($rows,$sonuc);
}
echo json_encode($rows);
Answer:
{…}0: Object { id: "30", userid: "YS3ul395jBDcBf8I", uniform_type: "Blazer", … }1: Object { id: "31", userid: "YS3ul395jBDcBf8I", uniform_type: "Blazer", … }2: Object { id: "32", userid: "YS3ul395jBDcBf8I", uniform_type: "Blazer", … }3: Object { id: "33", userid: "YS3ul395jBDcBf8I", uniform_type: "Blazer", … }amount: "10"color: "Preto"contract: "INCA"cost: "50"date: "2018-01-26 15:00:57"id: "33"place: "Nit"provider_id: "1"size: "1/2 Sem Gola"uniform_type: "Blazer"userid: "YS3ul395jBDcBf8I"__proto__: Object { … } uniform.php:307:13
Note that Object 33 is duplicated