For some reason the code isn't incriminating and I'm getting the error
Notice: Undefined variable: id
<?php
error_reporting(E_ALL); // Error engine - always TRUE!
ini_set('display_errors', TRUE); // Error display - FALSE only in production environment or real server
ini_set('log_errors', TRUE); // Error logging engine
ini_set('error_log', 'errors.log'); // Logging file path
session_start();
setlocale(LC_CTYPE, "en_US.UTF-8");
require_once "classes/Database.php";
$personsDB = new Database();
$page = $_GET["page"] ?? 0;
$thisScript = "get_records.php";
$id = $_SESSION['id'] ?? '';
$offset = 3;
$articlesPerLoad = 2;
try{
$q = $personsDB->prepare("SELECT reviewId, shopId ,review FROM reviews WHERE shopId = :id ORDER BY reviewId limit $articlesPerLoad offset :offset");
$q->bindValue(':id', $id, PDO::PARAM_INT);
$q->bindValue(':offset', $offset, PDO::PARAM_INT);
articles($q,$page,20,$articlesPerLoad,$thisScript);
}catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
function articles($q,$page,$howmany,$articlesPerLoad,$thisScript){
$nextPage=$page+$articlesPerLoad;
$q->execute();
$rows = $q->fetchAll(\PDO::FETCH_ASSOC);
foreach($rows as $i=>$row) {
echo "<article>";
echo $row['review'];
// echo "<img height=300 src='/people/images/{$row['reviewId']}{$row['review']}'>";
if ($articlesPerLoad==$i+1){
echo "<a class=more href='$thisScript?id={$id}&page={$nextPage}'>more</a>";
}
echo "</article>";
}
}
?>