I have a question regarding a delete function into php. Consindiring PHP I'm a real noob in this.
I want to make a delete link into a php loop.
This is my home.php:
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td class='info-item'>".$row["userID"]."</td>";
echo "<td class='info-item'>".$row["userName"]." </td>";
echo "<td class='info-item'>".$row["userLast"]."</td>";
echo "<td class='info-item'>".$row["userDegree"]."</td>";
echo "<td class='info-item'>".$row["userOrganization"]."</td>";
echo "<td class='info-item'>".$row["userIndustry"]."</td>";
echo "<td class='info-item'>".$row["userAddress-1"]."</td>";
echo "<td class='info-item'>".$row["userAddress-1"]."</td>";
echo "<td class='info-item'><a href='$delete'>Link</a></td>";
}
This line:
echo "<td class='info-item'><a href='$delete'>Link</a></td>";
is not working.
for $delete
I use this on top of my script:
$delete = "delete.php";
It goes to delete.php that looks like this.
ob_start();
include("dbconfig.php");
if(isset($_GET['userID'])!="") {
$delete=$_GET['userID'];
$delete=mysql_query("DELETE FROM tbl_users WHERE userID='$delete'");
if($delete)
header("Location:index.php");
else
echo mysql_error();
}
ob_end_flush();
But nothing appears to happen regarding the delete of a certain id that I clicked.
Please help.