I'm very new to web programming so I will try to explain my issue here! So basically I tried to get all the data from my query in PHP and push everything into an array in Javascript. The code below works for the first iteration, but it seems like after the first one, the rest just gets duplicated (it seems like the $i variable does not update?)
Can someone explain to me why is that and how should I fix it? Thanks!
...
$result = mysqli_query($con, $query);
$num_rows = mysqli_num_rows($result);
$i = 0;
$history_array = array();
if($num_rows > 0){
while($row = mysqli_fetch_array($result)){
array_push($history_array, $row);
}
}
?>
No comments:
Post a Comment