I have been trying to figure something out here and am having problems. What I have is a problem with outputting some info in a table. Here is what I have and the problem is in the "getstart_end" function. This should be a working copy if you want to run it and I have put in some sample times.

// $dend is actually how many hours from the start time. It is not a clock time in itself.
// So that would mean that a $dstart of 07:00:00 and a $dend of 6:00:00 would actually make
// the $dend time 13:00:00 (1pm)
createtemptable();
populatetemptable();
$dstart="07:00:00";
$dend="6:00:00";
deletetimes($dstart,$dend);
$dstart="18:00:00";
$dend="3:40:00";
deletetimes($dstart,$dend);
getstart_end();
droptemptable();

// This just creates the table and works
function createtemptable(){
$result=mysql_query("CREATE TEMPORARY TABLE IF NOT EXISTS aplayabletimes
(`min` time
) TYPE=MyISAM");
}

// This just populates the table in 5 minute increments and works
function populatetemptable(){
for($i=0;$i<1435;$i=$i+5){
$minutes=$minutes+5;
if($minutes=="60"){
$minutes="00";
$hours=$hours+1;
}
$time="$hours:$minutes:$seconds";
$result=mysql_query("INSERT INTO aplayabletimes
(min)
values
(\"$time\")");
}
}

/ / This deletes times from the table and works
function deletetimes($dstart,$dend){
list($hours,$minutes,$seconds)=split(":",$dstart);
list($houre,$minutee,$seconde)=split(":",$dend);
$minutee=$minutee+$minutes;
$houre=$houre+$hours;
if($minutee>=60){$minutee=$minutee-60;$houre=$houre=1;}
$dend="$houre:$minutee:00";
$result=mysql_query("DELETE FROM aplayabletimes WHERE min > '$dstart' AND min < '$dend'");
}

// Here is where I am having problems. I need it to give me the start time
// And the end time. There can be gaps in the table for times.
// It starts at 00:00:00 and goes to 23:55:00 (in 5 minute increments). Once time frames are deleted,
// it could have times from (example) 07:00:00 - 13:00:00 and another time frame from
// 18:00:00 to 21:40:00. What I need it to do is to output like this:
// "First Start Time - First End Time" newline
// "Next Start Time - Next End Time" newline
// etc....... (because there can be multiple start and end times)
// To determine if there is a new time block, there would be more than a 5 minute gap between
// the end of one time block and the start of another time block.
// The $i is just to grab the first block and I know there has to be a better way then this to do that too.
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
}else{

}
$i++;
}
}

// This just deletes the temporary table
function droptemptable(){
$result=mysql_query("DROP TEMPORARY TABLE playabletimes");
}


Thank You in advance for any help that you can give me on the problem.
Steve


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to