$b=array();
$selectTimeStampQuery = mysql_query("SELECT box1, box2, box3, box4, box5, box6, box7, box8, box9 FROM wallet3 WHERE uid='".$_SESSION['uid']."'");
$dateTimeCurr = date_create();
$dates = array();
while($row = mysql_fetch_assoc($selectTimeStampQuery)){
$dates[] = $row;
}
if($dates[0]['box2'] == '0' && $dates[0]['box3'] == '0' && $dates[0]['box4'] == '0' && $dates[0]['box5'] == '0' && $dates[0]['box6'] == '0' && $dates[0]['box7'] == '0' && $dates[0]['box8'] == '0'){
for($i=1;$i<9;$i++){
$b[$i] = "N";
}
$dta = date_create($dates[0]['box1']);
$dtDiff = $dateTimeCurr->diff($dta);
$dtaFormat = $dtDiff->format("%a-%h");
$dtaParts = explode('-', $dtaFormat);
if($dtaParts[0] == '0'){
if($dtaParts[1] > '8'){
$b[0] = 'Y';
}
else{
$b[0] = 'N';
}
}
elseif($dtaParts[0] > '0'){
$b[0] = 'Y';
}
else{
$b[0] = 'N';
}
}
else{
$dates1 = array();
foreach($dates[0] as $time){
$dates1[] = date_create($time);
}
$diffArr = array();
foreach($dates1 as $dt){
if($dt == '0'){
$diffArr[] = '0';
}
else{
$dtt = $dateTimeCurr->diff($dt);
$dttFor = $dtt->format("%a-%h");
$dttParts = explode('-', $dttFor);
$diffArr[] = $dttParts;
}
}
for($i=0;$i<=8;$i++){
if($diffArr[$i]=='0'){
$b[$i] = 'N';
}
else{
if($diffArr[$i][0] == '0'){
if($diffArr[$i][1] > '8'){
$b[$i] = 'Y';
}
else{
$b[$i] = 'N';
}
}
elseif($diffArr[$i][0] > '0'){
$b[$i] = 'Y';
}
}
}
}
}
This is supposed to show each of the nine boxes, one every 8 hours. but I am Always etting 8 of them showing in less than a day