<?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"];
        ?>