Jump to content

[SOLVED] Deleting a row


lmhart

Recommended Posts

I have a page that lists the user and has an option to delete the record. But I can not get it to delete the record. I believe that I am passing the correct information but it just will not delete. It just goes to delete.php and displays a blank name. The pop up that I have before it switches pages post the correct info. Where am I going wrong?

 

 
->addColumnAfter('actions', '<a href="#edit.php?id=$user_id$">Edit</a>
- <a href="delete.php?id=$id_user$" onclick="return confirm('Are you sure you want to delete user $id_user$?')">Delete</a>
', 'Actions', array('align' => 'center'))

 

delete.php

 
<php

include 'dbc.php';
$id_user = $_GET[id];
echo $id_user;
echo "<br>";
echo $id;
mysql_query("Delete From users where id_user = $id_user");

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/178474-solved-deleting-a-row/
Share on other sites

generally, if you print your query statement you can see the problem. if you printed it you would probably see

 

"Delete From users where id_user = $id_user"

 

when in fact you want

 

"Delete From users where id_user = [the actual user ID]"

 

try this:

 

mysql_query("Delete From users where id_user = '".$id_user."'");

Well I took a close look at the code and I was missing the first ? at the top <?

 

here is code that works!  Thanks for all the help

<?php

include 'dbc.php';


$id_user = $_GET[id];

echo "the user to be deleted is - ";
echo $id_user;
echo "<br>";
echo $id;

mysql_query("Delete From users where id_user = ".$id_user."");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.