Thursday, 30 August 2018

The mysqli query does not update in the while loop

I am building a script to display some 24 hour charts. I am attempting to make 12 charts. One 24 hour (last hour) chart for each five minute data set i have collected. I am running accross an issue where my mysql command will not update the $hour_position. I've read many while loop inside while loop questions and have tried to construct a foreach alternative, and also tried to reset the query array, but none of this has worked. Any comments or links to another thread that can solve this problem would be appreciated. Thanks in advance.

$hour_position = 00;
$htime = -1;
$date = date('Y-m-d H:i:s');
$date = strtotime($date);
$date = strtotime($htime." day", $date);
$date = date('Y-m-d H:i:s',$date);

while($hour_position < 60){
    $price_history_qry = mysqli_query($con,"SELECT * FROM `dbTable` WHERE `server_time` > '$date' AND EXTRACT(MINUTE FROM `server_time`) like $hour_position ORDER BY `server_time` ASC");
    while($result = mysqli_fetch_array($price_history_qry)){
        //Create a couple of arrays to build a chart.
    }
    //Build chart here
    echo $chart;
    $hour_position = $hour_position +05;
}


Try putting $hour_position in quote like
      ' $hour_position '

or you can use
      ". $hour_position ."

0 comments:

Post a Comment