I have start and finish times for my users
Times are in seconds in db and converted in gmdate() in page please keep in mind when you see the integers.
user1 startTime = 9:00; finishTime = 10:00;
user2 startTime = 12:00; finishTime = 1:00;
<?php
if ($results = $db->query("SELECT * FROM times WHERE Id = $user->data()->id")){
if($results->num_rows){
$value = 1800;
while($row = $results->fetch_array()){
//This will return the startTime, finishTime, and any blocks of time in between them
for($n_block = $row['timeStart']; $n_block <= $row['timeFinish']; $n_block+=$value){
echo "$n_block<br>";
}
}
}
}
?>
The desired results are:
32400
34200
36000
43200
45000
46800
But I need to put the results in an array that is accessed outside the loop
// need to get above while and for loop results in this array outside the loops
$excludes = array();
if I use $start = ""; please see http://pastie.org/9784700
if I take the for loop out of the while loop please see http://pastie.org/9784732
How do I achieve the desired results? Meaning how can I access the results of the combined loops outside of the loops?
var_dump($row);
array(18) {
[0]=> string(1) "5"
["appointmentCount"]=> string(1) "5"
[1]=> string(2) "23"
["technicianId"]=> string(2) "23"
[2]=> string(2) "22"
["customerId"]=> string(2) "22"
[3]=> string(10) "1417129200"
["appointmentDay"]=> string(10) "1417129200"
[4]=> string(5) "43200"
["appointmentStart"]=> string(5) "43200"
[5]=> string(5) "46800"
["appointmentFinish"]=> string(5) "46800"
[6]=> string(8) "FULL SET"
["serviceName"]=> string(8) "FULL SET"
[7]=> string(2) "50"
["serviceCost"]=> string(2) "50"
[8]=> string(8) "November"
["appointmentMonth"]=> string(8) "November"
}
array(18) {
[0]=> string(1) "6"
["appointmentCount"]=> string(1) "6"
[1]=> string(2) "23"
["technicianId"]=> string(2) "23"
[2]=> string(2) "22"
["customerId"]=> string(2) "22"
[3]=> string(10) "1417129200"
["appointmentDay"]=> string(10) "1417129200"
[4]=> string(5) "32400"
["appointmentStart"]=> string(5) "32400"
[5]=> string(5) "36000"
["appointmentFinish"]=> string(5) "36000"
[6]=> string(8) "Nail Tip"
["serviceName"]=> string(8) "Nail Tip"
[7]=> string(2) "30"
["serviceCost"]=> string(2) "30"
[8]=> string(8) "November"
["appointmentMonth"]=> string(8) "November"
}
<?php
if ($appointmentResults = $db->query("SELECT * FROM appointments WHERE technicianId = $userid")){
if($appointmentResults->num_rows){
$start = "";
$finish = "";
$value = 1800;
while($row = $appointmentResults->fetch_array()){
$start .= $row['appointmentStart'] . '<br>';
$finish .= $row['appointmentFinish'] . '<br>';
for($n_block = $row['appointmentStart']; $n_block <= $row['appointmentFinish']; $n_block+=$value){
echo "$n_block</br>"
}
}
}
}