I'm trying to display a single record (row) from the database when a user clicks on a link. There's a page where all the records are displayed and there's a link next to every record. When the user clicks on the link it goes to a new page where I'm trying to display the record that the user clicked on.
The link is like this:
Which is one of about six items displayed, some of which are from the database. When they click on this link the page is directed to delete.php which has this:
I've tried while loops, for loops and if statements and none of them work. I thought it was a for loop, but couldn't make it work.
The link is like this:
Code:
echo '<a href="delete.php">Delete</a>';
Code:
<?php
include ('includes/DbCon.php');
$query = 'SELECT headline, body, image, newsDate FROM news WHERE id = '. intval($_GET['$id']);
$result = $mysqli->query ($query);
while($row = $mysqli->fetch_array) {
{
echo "<table>";
echo "<tr><td>";
echo $row['headline'];
echo "</td></tr>";
echo "</td><td>";
echo $row['body'];
echo "</td><td>";
echo $row['date'];
echo "</td><td>";
echo "<p><img src=".$dir.$row['image']." alt=''></p>";
echo "</td></tr>";
}
echo "</table>";
mysqli_close($mysqli);
?>
Comment