now, next and later script

DDDDec

Tongue Boxing Champion 2023
May 30, 2017
405
248
how it works:
shows the current next and later event by the hour.

sql:
SQL:
DROP TABLE IF EXISTS `cms_events`;
CREATE TABLE `cms_events` (
  `id` int(11) NOT NULL,
  `event_name` varchar(255) NOT NULL,
  `time` varchar(255) NOT NULL,
  `day` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

css:
CSS:
.events {
    width: 100%;
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-gap: 1%;
}
.event-image {
    display: inline-block;
    height: 130px;
    width: 100;
    overflow: hidden;
    padding-right: 10px;
    padding-bottom: 10px;
    color: white;
    border-radius: 3px;
    display: inline-block;
    background-image: url('http://localhost/cms_images/dump/lpromo_nov20_gen.png');
    background-repeat: no-repeat;
    background-position: bottom right;
    font-weight: bold;
    text-align: center;
}
.event-time {
    padding: 10px;
    margin-top: 10px;
    width: 70%;
    background-color: #00000075;
    border-radius: 3px;
    display: inline-block;
    margin-left: 10px;
}
.event-type {
    padding: 10px;
    margin-top: 10px;
    width: 70%;
    background-color: #00000075;
    border-radius: 3px;
    display: inline-block;
    margin-left: 10px;
}

php:
PHP:
class events {
 
    public function timeCheck($time) {
    
        if ($time == '25') {
        
            $time = '0';
        
        }
    
        if ($time == '26') {
        
            $time = '1';
        
        }
    
    }
 
    public function now_plugin() {
    
        global $db;
    
        $time = date('H') - 1 + 1;
        $day = date('N');
    
        $now_plugin = $db->prepare("
        SELECT * FROM cms_events WHERE time = :time AND day = :day
        ");
        $now_plugin->bindParam(":time", $time);
        $now_plugin->bindParam(":day", $day);
        $now_plugin->execute();
    
        if ($now_plugin->RowCount() > 0) {
        
            $now_plugin_data = $now_plugin->fetch();
            echo "
            <div class='event-image'>
             <div class='event-time'>{$now_plugin_data['time']}:00</div>
             <div class='event-type'>{$now_plugin_data['event_name']}</div>
            </div>
            ";
        
        } else {
            echo "
            <div class='event-image'>
             <div class='event-time'>$time:00</div>
             <div class='event-type'>NO EVENT BOOKED</div>
            </div>
            ";
        }
    
    }
 
    public function next_plugin() {
    
        global $db;
    
        $time = date('H') - 1 + 2;
        $day = date('N');
    
        self::timeCheck($time);
    
        $next_plugin = $db->prepare("
        SELECT * FROM cms_events WHERE time = :time AND day = :day
        ");
        $next_plugin->bindParam(":time", $time);
        $next_plugin->bindParam(":day", $day);
        $next_plugin->execute();
    
        if ($next_plugin->RowCount() > 0) {
        
            $next_plugin_data = $next_plugin->fetch();
            echo "
            <div style='opacity: 0.5;' class='event-image'>
             <div class='event-time'>{$now_plugin_data['time']}:00</div>
             <div class='event-type'>{$now_plugin_data['event_name']}</div>
            </div>
            ";
        
        } else {
            echo "
            <div style='opacity: 0.75;' class='event-image'>
             <div class='event-time'>$time:00</div>
             <div class='event-type'>NO EVENT BOOKED</div>
            </div>
            ";
        }
    
    }
 
    public function later_plugin() {
    
        global $db;
    
        $time = date('H') - 1 + 3;
        $day = date('N');
    
        self::timeCheck($time);
    
        $later_plugin = $db->prepare("
        SELECT * FROM cms_events WHERE time = :time AND day = :day
        ");
        $later_plugin->bindParam(":time", $time);
        $later_plugin->bindParam(":day", $day);
        $later_plugin->execute();
    
        if ($later_plugin->RowCount() > 0) {
        
            $later_plugin_data = $later_plugin->fetch();
            echo "
            <div style='opacity: 0.5;' class='event-image'>
             <div class='event-time'>{$now_plugin_data['time']}:00</div>
             <div class='event-type'>{$now_plugin_data['event_name']}</div>
            </div>
            ";
        
        } else {
            echo "
            <div style='opacity: 0.5;' class='event-image'>
             <div class='event-time'>$time:00</div>
             <div class='event-type'>NO EVENT BOOKED</div>
            </div>
            ";
        }
    
    }
 
}

image i used:
You must be registered for see images attach


put this anywhere before you run the script, change the timezone if your not using londons timezone:
date_default_timezone_set('Europe/London');

how it looks:

You must be registered for see images attach


Alternative:
 
Last edited:

DDDDec

Tongue Boxing Champion 2023
May 30, 2017
405
248
ill add a screenshot and of it working and also i wanted to put it here coz i want constant feedback on whatever i wonna give out is that fine or no if not just move to the release section :)
 

Joe

Well-Known Member
Jun 10, 2012
4,090
1,918
ill add a screenshot and of it working and also i wanted to put it here coz i want constant feedback on whatever i wonna give out is that fine or no if not just move to the release section :)
Thread moved! Get the screenshot added asap so we can approve the thread mate :)
 

TesoMayn

Boredom, it vexes me.
Oct 30, 2011
1,482
1,482
Change the host, not going to log in with social media to download a SQL file

Also, you should give more detail on what it actually is, not just "SQL for timetable" lol

You could (and should) just attach the file to your thread.
 

DDDDec

Tongue Boxing Champion 2023
May 30, 2017
405
248
That hosting site you're using is absolute cancer. You can't even download without logging in via Social Media
Didn't even realize never used it and just wanted a quick upload I'll change it later

And @TesoMayn what do u mean instead of uploading a seeperate file I just put the query in the class.radio.php, what's wrong with that saves downloading seperate files.

Also wouldn't let me attach a file that isn't an image.
 

Users who are viewing this thread

Top