Here's what I'm trying to do. I'm trying to echo blog posts stored in my database. Simple enough, but I want them to be redirected to view_post.php to show the full post, when they click on the little preview. Here's my code:
<?php
session_start();
require_once('required/db.php');
$_SESSION['admin'] = false;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>WillWam - Blog</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/style.css" type="text/css">
<link rel="ico" href="assets/favicon.ico">
</head>
<body>
<nav><h2 class="title">The Blog</h2></nav>
<?php
$sql="SELECT id,title,author,body FROM posts ORDER BY id DESC";
if ($result=mysqli_query($con,$sql))
{
// Fetch one and one row
while ($row=mysqli_fetch_row($result))
{
printf('<a href="view_post.php"><div class="row"><div class="row-inner"><p><strong>%s</strong> | %s |</p></div></div></a>', $row[0],$row[1],$row[2]);
}
// Free result set
mysqli_free_result($result);
}
mysqli_close($con);
?>
<div class="top-margin wrapper"><div class="container"><p>Administrator? <a href="/admin/">Click here</a>.</p></div></div>
</body>
</html>
How would I go about making the preview row a link dynamically (such as view_post.php?id=1)? What would I put in view_post.php?