I have a comment section on my index.php page. (like I have displayed here) I have a delete link that sends you to the delete page. I want to be able to delete that specific ID when it is clicked. index.php
<div class='commentnest'>
<p id='id'> ".$row['id']."</p>
<p id='user'> ".$row['user'].":</p>
<p id='comment'>".$row['usercomment']." </p>
<p id='time'>".$row['timestamp']."</p>
<a href='delete.php?=".$row['id']."'>Delete</a>
</div>
delete.php page
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "DELETE FROM commenttable WHERE id=id";
if (mysqli_query($conn, $sql)) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
every time I send a specific comment there, it deletes all the comments. I know it's because I'm not stating which ID to select, but i'm having a hard time figuring that out.
Thanks for any help!