Friday, 13 September 2013

Getting date and time from mysql to output into html table

Getting date and time from mysql to output into html table

I have been working on this thing for awhile now and cannot figure it out.
What I'm wanting to do is run a function that will call all my records for
a specific date and output them in an html table. I can do it by running
the query inside the loop but I'm wanting to learn how to use arrays to
accomplish this.
function getAll(){
include('inc/connect.php');
$a = $data->query("SELECT * FROM bookings WHERE active = 'true'");
$args = array();
while($b = $a->fetch_array()){
$t1 = strtotime($b["endtime"]);
$t2 = strtotime($b["starttime"]);
$diff = $t1 - $t2;
$hours = $diff / ( 60 * 60 );
$args[] = array(
'start' => $b["starttime"],
'end' => $b["endtime"],
'span' => $hours
);
}
return $args;
}
Above is the function that I run to get all and return the arrays but I'm
very new to arrays and have no idea how to run them against the below.
$interval = 1800; // Interval in seconds
$date_first = "02-09-2013 00:00:00";
$date_second = "03-09-2013 00:00:00";
$time_first = strtotime($date_first);
$time_second = strtotime($date_second);
$go = getAll();
for ($i = $time_first; $i <= $time_second; $i += $interval){
$timeOut = date('d-m-Y H:i', strtotime("+30 minutes", $i));
//////I WOULD LIKE TO RUN THE ARRAY CALLED BY $go HERE TO SEE IF start ==
$timeOut/////
}
I'm try to get the following results onto the html table. Thanks in
advance for the help.
http://i.stack.imgur.com/vMFH7.jpg

No comments:

Post a Comment