<?php

ob_start();
session_start();
$event_id = $_GET["id"];
require_once 'class.event.php';
$event = new Event($event_id);
$event_field = $event->get_event();
$event_image_field = $event->get_event_image($event_id);
?>

<div class="page-header">
  <div class="row">
    <div class="col-md-6">
      <blockquote>
        <p style="font-size: 92px;"><?php 
echo $event_field["name"];
?>
</p>
      </blockquote>
    </div>
    <div class="col-md-6">
      <a href="#" class="thumbnail pull-right" style="width: 48%;">
        <img src="data:image;base64,<?php 
echo $event_image_field['event_image'];
?>
">
      </a>
    </div>
  </div>
</div>
<?php

require_once 'class.event.php';
$event = new Event();
$events = $event->get_recent_events();
?>
<blockquote><h2>Recent Events</h2></blockquote>
<div class="row">
  <?php 
if ($events->num_rows > 0) {
    // output data of each row
    while ($row = $events->fetch_assoc()) {
        $event_image_field = $event->get_event_image($row["id"]);
        ?>
      <div class="col-sm-6 col-md-3">
        <div class="thumbnail">
          <?php 
        if (!empty($event_image_field['event_image'])) {
            echo '<img src="data:image;base64,' . $event_image_field['event_image'] . '">';
        } else {
            echo '<img style="height: 128px !important;" src="assets/images/notfound.png">';
        }
        ?>
          <div class="caption">
            <h3><?php 
        echo $row["name"];
        ?>
</h3>
            <?php 
        $description = strlen($row["description"]) > 13 ? substr($row["description"], 0, 150) . '...' : $row["description"];
        ?>