Wednesday, November 28, 2018

PHP variable does not update inside of the Javascript while loop

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...