/**
 * Print Latest newsItems preview format
 *	
 * @param int $numberOfPosts
 * @return
 */
function retrieveBlogpostsPreview($numberOfPosts)
{
    include_once 'blogpost.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 blogposts ORDER BY sortdate DESC, created DESC \n\t\t\tLIMIT " . $numberOfPosts;
    $stmt = $db->prepare($sql);
    $stmt->execute();
    $counter = 0;
    echo "<div class='body-content'>";
    while ($row = $stmt->fetch()) {
        //echo in case of a new row of previews (3 per row): adds an empty row as a spacer
        if ($counter % 3 == 0 && $counter > 0) {
            echo <<<ROW
\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t\t<div class='body-content'>
\t\t\t\t\t\t<div class="row news">
\t\t\t\t\t\t\t<div class="col-md-3 col-sm-0">
\t\t\t\t\t\t\t\t&nbsp;
\t\t\t\t\t\t\t</div>
ROW;
        }
        //echo blogpost
        $blogpost = new Blogpost(FALSE);
        $blogpost->updateParameters($row['id']);
        echo $blogpost->formatPreview();
        flush();
        $counter++;
    }
    echo "</div>";
    $stmt->closeCursor();
}