I have to run mysql query in a for loop like this
$date_start = '2017-01-01';
$date_end = '2017-01-10';
while ($date_start < $date_end){
$sql ("SELECT id FROM mytable WHERE mydate = '$data_start'"); [<--edit]
$result = $db->query($sql);
$f = $result->fetch();
echo 'result is : '.$f['id'];
$date_start = date('Y-m-d', strtotime($date_start. ' + 1 days'));
}
ID result was always related to first $date_start, then first sql query...
How to wait php for mysql to finish query?
EDIT.:
Ok, there was a mistake when I create the loop here, but is a distraction! It's not a copy/paste
After this I wrote
ID result was always related to first $date_start, then first sql query...
This means that is not a code problem, the loop works, else I have a php error!
I will try with MYSQL error reporting