Jump to content

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."");

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.