When I run this:
for ($Count = 0; $Count <= 6; $Count++)
{
$date = date_create($StartDate);
date_add ($date, date_interval_create_from_date_string($Count . 'days'));
$IncDate = date_format($date, 'Y-m-d');
echo $Count . ' !! ' . $IncDate . '<br>';
}
I get:
0 yy 25842 qq Timothy qq Lear qq 5804307158
0 !! 2013-01-29
1 !! 2013-01-30
2 !! 2013-01-31
3 !! 2013-02-01
4 !! 2013-02-02
5 !! 2013-02-03
6 !! 2013-02-04
0 yy 82233 qq Darron qq Kolb qq 5804307159
0 !! 2013-01-29
1 !! 2013-01-30
2 !! 2013-01-31
3 !! 2013-02-01
4 !! 2013-02-02
5 !! 2013-02-03
6 !! 2013-02-04
old begins here
When I add a query and run this code:
for ($Count = 0; $Count <= 6; $Count++)
{
$date = date_create($StartDate);
date_add ($date, date_interval_create_from_date_string($Count . 'days'));
$IncDate = date_format($date, 'Y-m-d');
echo $Count . ' !! ' . $IncDate . '<br>';
$query = "SELECT * FROM TOAWorkorders WHERE TechNum = $TechNum AND WorkDate = '$IncDate'";
if ($result = $mysqli->query($query))
{
printf("Select returned %d rows.\n", $result->num_rows);
$result->close();
}
}
I get:
0 yy 25842 qq Timothy qq Lear qq 5804307158
0 !! 2013-01-29 Select returned 5 rows.
1 !! 2013-01-30 Select returned 5 rows.
2 !! 2013-01-31 Select returned 4 rows.
3 !! 2013-02-01 Select returned 5 rows.
4 !! 2013-02-02 Select returned 0 rows.
5 !! 2013-02-03 Select returned 0 rows.
6 !! 2013-02-04 Select returned 5 rows.
old begins here
The query returns the expected result, but the loop dies at the query in the first iteration. Where did the numbers for Darron Kolb go?