This is the link to trigger the code part: <a href='?cmd=deletetype3&id=$picid'>Delete</div> Code (PHP): This query should be done: if($_GET["cmd"]=="deletetype3"){ $deletepic = mysql_query("DELETE FROM userbooks WHERE ename = '$ename' AND ID = '$picid'");} Code (PHP): picid = 22 (for example) ename = logged user. (bob?) Instead of deleting the matching ones, it whipes out the whole table entries. Why is that? Helps appreciated.
I dont know why it does that. But I guess your ID is stored as an int? If so, then you should remove the qoutes(') around $picid in the sql query
To ensure that all the variables are correct i tried to post em into the url bar with this piece of code: if($_GET["cmd"]=="deletetype3"){ header("Location: index.php?name=$ename&id=$picid"); } Code (PHP): Results: index.php?nimi=/&%¤#/@gmail.com&id=23 All the way it should be. Maybe its a some kind of a bug?
Try this; <a href='?cmd=deletetype3&id=<?=$picid?>'>Delete</div> PHP: if($_GET["cmd"]=="deletetype3"){ $deletepic = mysql_query("DELETE FROM userbooks WHERE ename = '" . $ename . "' AND ID = '" . $_GET['picid'] . "'); } PHP:
Thanks for your reply but it didnt delete anything. No errors, nothing. Did fix that syntax error though. Im thinking of having a popup conformation screen and use GET/POST functions there. Done similar things before.
I noticed a small mistake in my code; Also try the code below and run the echoed query in PHPMYAdmin and see what happens. Might be a table syntax error (e.g. wrongly named field etc) if($_GET["cmd"]=="deletetype3"){ $qry = "DELETE FROM userbooks WHERE ename = '" . ename . "' AND ID = '" . $_GET['picid'] . "'"; echo $qry; $deletepic = mysql_query($qry); } PHP: