function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
} else {
list($houre,$minutee,$seconds)=explode(":",$i);
$minutee=$minutee+5;
if($minutee>=60){$minutee=$minutee-60;$houre=$houre+1;}
$tmp = implode(':',array(str_pad($houre,2,'0',STR_PAD_LEFT) ,str_pad($minutee,2,'0',STR_PAD_LEFT),'00'));
if($tmp != $row->min) { // there is a gap
//echo $row->min ." != $tmp<br>";
echo $i ."<br>\n"; // print previous time as end
echo $row->min . " - "; // print this time as new start
}
$i = $row->min; // keep this new time for next loop
}
//echo $i." - $tmp --tmp<br>\n";
//echo $row->min."<br>\n";
}
echo $i ."<br>\n"; // print last row
}
Steve Buehler wrote:
Ok. That output was my fault. I had an error in one of my other functions. I needed to set $hours to "00" to start with in my populatetemptable() function. Now my output is:
00:05:00 - 00:05:00
00:05:00 - 00:10:00
00:10:00 - 00:15:00
00:10:00 - 00:20:00
00:15:00 - 00:25:00
00:15:00 - 00:30:00
Problem is that it isn't giving me just the start and end times. I will keep working on it.
Thanks
Steve
At 12:48 PM 11/14/2002 -0600, you wrote:
Thanks for the help, but that is not actually producing the desired results either. This returns the following results:
00:00:05 - 00:00:05
00:00:05 - 5
00:00:05 - 10
00:00:05 - 15
00:00:10 - 20
00:00:10 - 25
00:00:10 - 30
00:00:10 - 35
00:00:15 - 40
00:00:15 - 45
00:00:15 - 50
00:00:15 - 55
00:00:20 - 60
00:00:20 - 65
I am not going to post all of them. :)
Here is the code that is now in the getstart_end() function. I had to change the line that you had because the 5 minutes would give an error. I just took out the "minutes" part.
$tmp = $i+5 minutes; // add 5 minutes to $i, implement it yourself
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
}else{
$tmp = $i+5; // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) { // there is a gap
echo $i ."<br>\n"; // print previous time as end
echo $row->min . " - "; // print this time as new start
}
$i = $tmp; // keep this new time for next loop
}
}
echo $row->min ."<br>\n"; // print last row
}
At 07:09 PM 11/14/2002 +0100, you wrote:
Untested, but should work Steve Buehler wrote:function getstart_end(){ $result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min"); while(($row=mysql_fetch_object($result))){ if(!$i){ echo $row->min . " - ";$i=$row->min;}else{$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself if($tmp != $row->min) { // there is a gap echo $i ."<br>\n"; // print previous time as end echo $row->min . " - "; // print this time as new start } $i = $tmp; // keep this new time for next loop} }echo $row->min ."<br>\n"; // print last row}-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3-- 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 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3-- 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