I have a database which contains 2 tables. In the second table there are numerous records and I'm trying to echo out the latest id (MAX id) to the page using PHP. There is something wrong with my code and I don't know what that is:
$sqlCount = "SELECT MAX(id) FROM records";
$sql = "SELECT id,preview,description FROM records";
$pn = (isset($_GET['pn'])) ? $_GET['pn'] : 1;
$res = upagination($con, $sql, $sqlCount, $pn, 6);
$list .="<table border=0>";
foreach ($res['rows'] as $row) {
$list .="<tr>";
$list .="<td>" . $row['id'] . "</td><td>" . $row['preview'] . "</td><td>" . $row['description'] . "</td>";
$list .="</tr>";
}
$list .="</table>";
$paginationCtrls = "";
if (isset($res['backLink'])) {
$paginationCtrls .= "<a href=\"{$_SERVER['PHP_SELF']}?pn= {$res['backLink']}\">Previous</a>";
}
if (isset($res['numbers'])) {
foreach ($res['numbers'] as $number) {
if ($number === $res['current']) {
$paginationCtrls .= "$number";
}
(some deleted code to shorten this a little)
}
}
?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css"></style>
<title>Humorweb</title>
<meta name="keywords" content="videos">
<meta name="description" content="Humorwebsite.org -collection of the funniest videos and photos from the internet!-">
<link rel="stylesheet" type="text/css" href="https://www.humorwebsite.org/style_main.css">
</head>
<body>
<div id="container">
<div id="logo"> </div>
<div id="sidebar">
<div id="links">
<a href="https://www.humorwebsite.org/">HOME</a>
<a href="https://www.humorwebsite.org/videos.php">VIDEOS</a>
<a href="https://www.humorwebsite.org/photos.php">PHOTOS</a>
<a href="https://www.humorwebsite.org/about.php">ABOUT</a>
</div>
</div>
<div id="context">
<div id="context-text"></div>
<div id="context-kuva">
<br>
<div id="nakki">
<?php echo $list; ?>
</div>
</div>
</div>
</div>
The last row I'm trying to echo out is the $list
variable, but I get nothing. I have made a CSS on this file and define width, height, position, and float properties, but end up getting nothing from database.