Jump to content

Timetable Help


Plug-in

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.