Plug-in Posted August 6, 2011 Share Posted August 6, 2011 Hello, I'm having a lot of trouble trying to achieve something. I've got a timetable that starts at the current hour and shows four more hours (current is 10 so it would shout 10, 11, 12, 1, 2) but on the sides I have arrows that change it so you can see the next five hours but even with my code to prevent it the numbers always end up above 12 or below 0 (negatives). Here is the code the displays the times: <?php $time = $t->current(); ?> <div id='arr_left' onclick='show(<?php echo $time-5; ?>);'><!-- Left Arrow --></div> <div id='content'><?php echo $t->hour(0, $time); ?></div> <div id='bar'></div> <div id='content'><?php echo $t->hour(1, $time); ?></div> <div id='bar'></div> <div id='content'><?php echo $t->hour(2, $time); ?></div> <div id='bar'></div> <div id='content'><?php echo $t->hour(3, $time); ?></div> <div id='bar'></div> <div id='content'><?php echo $t->hour(4, $time); ?></div> <div id='arr_right' onclick='show(<?php echo $time+5; ?>);'><!-- Right Arrow --></div> If you notice the JQuery then I'll show you that at the end if there's an error in there but here is the actions.php where the classes are: <?php date_default_timezone_set('Australia/Perth'); class time { function hour($num, $time) { $date = $time + $num; if (strpos($date, '-')) { $date = str_replace('-', '', $date); $date = ($date<(-13))? $date-12 . "PM" : $date . "AM"; return $date; } else { $date = ($date>12) ? $date-12 . "AM" : $date . "PM"; return $date; } } function current() { $dfunc = date('h'); $date = (isset($_GET['n'])) ? $_GET['n'] : $dfunc-1+1;; return $date; } } $t = new time; ?> Here is the JQuery, it is linked in the <head></head> tags to the JQuery library. <script type='text/javascript'> function show(date) { $('body').load('index.php?n=' + date); } </script> Again I would really appreciate it if you could help me Link to comment https://forums.phpfreaks.com/topic/244039-timetable-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.