I am trying to deleting a row in my database by clicking a link in my PHP based web-page. All my database connections and table selections work well but while sending the primary key to the page that I am doing the delete operation it seem sthat I cannot send the right information since it is not deleting anything. Am I doing something wrong?
I am sending the information like this:
echo "<td><a href= 'delete.php?pid='{$_POST['id']}''> Delete </a></td>";
And deleting like this:
$del="DELETE FROM sca WHERE pid = '{$_POST['id']}'";
Thanks
If your delete query is on delete.php you want to access WHERE pid = '{$_GET['pid']}' from the URL as you will have lost your post data when clicking the link.
Are you sure that "$_POST['id']" returns something?
echo '<td><a href="delete.php?pid=' . $_POST['id'] . '">Delete</a></td>';
You have to use $_GET variable there:
$id = (int) $_GET['id'];
$del = "DELETE FROM `sca` WHERE `pid` = $id";