File: fwphp/glomodul/z_examples/book_video/gallery_powers/blog_word.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/gallery_powers/blog_word.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/gallery_powers/blog_word.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 1 month ago
Size: 1,570 bytes
 

Contents

Class file image Download
<?php
include '../includes/title.php';
require_once
'../includes/connection.php';
require_once
'../includes/utility_funcs.php';
// create database connection
$conn = dbConnect('read', 'pdo');
$sql = 'SELECT article_id, title, LEFT(article, 100) AS first100
        FROM blog ORDER BY created DESC'
;
$result = $conn->query($sql);
$errorInfo = $conn->errorInfo();
if (isset(
$errorInfo[2])) {
   
$error = $errorInfo[2];
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Japan Journey <?= $title ?? ''; ?></title>
    <link href="../styles/journey.css" rel="stylesheet" type="text/css" media="screen">
</head>

<body>
<header>
    <h1>Japan Journey </h1>
</header>
<div id="wrapper">
    <?php require '../includes/menu.php'; ?>
<main>
        <?php
       
if (isset($error)) {
            echo
"<p>$error</p>";
        } else {
            while (
$row = $result->fetch()) { ?>
<h2><?= safe($row['title']) ?></h2>
                <p>
                    <?php
                    $extract
= $row['first100'];
                   
// find position of last space in extract
                   
$lastSpace = strrpos($extract, ' ');
                   
// use $lastSpace to set length of new extract and add ...
                   
echo safe(substr($extract, 0, $lastSpace)) . '... ';
                   
?>
<a href="details.php?article_id=<?= $row['article_id']; ?>"> More</a>
                </p>
            <?php }
        }
?>
</main>
    <?php include '../includes/footer.php'; ?>
</div>
</body>
</html>

For more information send a message to info at phpclasses dot org.