Example #1
0
/**
 * Print Latest events preview format
 *	
 * @param int $numberOfPosts
 * @return
 */
function retrieveEventsPreview($numberOfPosts)
{
    include_once 'event.inc.php';
    include_once 'db.inc.php';
    //Open a database connection and store it
    $db = new PDO(DB_INFO, DB_USER, DB_PASS);
    //compose sql query
    $sql = "SELECT id\n\t\t\tFROM events ORDER BY sortdate DESC, created DESC \n\t\t\tLIMIT " . $numberOfPosts;
    $stmt = $db->prepare($sql);
    $stmt->execute();
    $counter = 0;
    while ($row = $stmt->fetch()) {
        //echo in case of a new row of previews (3 per row)
        if ($counter % 3 == 0 && $counter > 0) {
            echo <<<ROW
\t\t\t<div class="col-md-3 col-sm-0">
\t\t\t\t&nbsp;
\t\t\t</div>
ROW;
        }
        //echo blogpost
        $event = new Event(FALSE);
        $event->updateParameters($row['id']);
        echo $event->formatPreview();
        flush();
        $counter++;
    }
    $stmt->closeCursor();
}