Пример #1
0
$articlesToShow = $articles->getArticlesFromDb($p);
//Retrieves articles for page number
for ($i = 0; $i < $articlesToShow->num_rows; $i++) {
    //Runs through the 5 articles
    $articlesToShow->data_seek($i);
    $article = $articlesToShow->fetch_assoc();
    //Fetches relavent article
    echo "<h1><a href='post.php?id=" . $article["ID"] . "'>" . $article["Title"] . "</a></h1>";
    //Title of article
    echo "<h3>By: " . $article["Author"] . "</h3>";
    //Author of article
    $content = $article["Content"];
    if (strlen($content) > 100) {
        $content = substr($article["Content"], 0, 1000) . "... <a href='post.php?id=" . $article["ID"] . "'>Read More</a>";
    }
    echo "<p>" . $content . "</p>";
    //Main content of article
    echo "<P>" . $article["Date"] . "</p>";
    //Date article was created
}
if ($articles->newVisible()) {
    //Displays buttons depending on whether article methods return true
    echo "<a href='index.php?p=" . ($p - 1) . "'>Previous Page</a>";
}
if ($articles->oldVisible()) {
    echo '<a href="index.php?p=' . ($p + 1) . '">Next Page</a>';
}
?>
</body>
</html>