DDDDec
Tongue Boxing Champion 2023
- May 30, 2017
- 441
- 275
how it works:
shows the current next and later event by the hour.
sql:
css:
php:
image i used:
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:
Alternative:
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:
You must be registered for see links
Last edited: