Jump to content

deleting contacts


ozzie135

Recommended Posts

I am quite new to php and am writing an application that needs to be able to delete users from the database. To do this I am extracting all users from the database and echoing them to the page in a HTML table with two columns. The first is the username and the second is an image representing the delete operation (ie. the user clicks the delete image and the user should be deleted from the database).

 

I am quite unsure as to how to go about this? Is the best way to add an onclick() function to each image and pass the username as a querystring to the deletecoontact.php page? The code below might explain this better:

 

<IMG src="images/delete.png" onclick="window.open('deletecontact.php?id=<?=$username?>','newwindow','width=560,height=400')" name="submit"> 

 

Is this the best way to do it, or is there a more simple way of handling the onclick event?

 

Any help would be greatfully received.

 

 

Link to comment
Share on other sites

Thats a great idea. The only issue I have is how do I then refresh the list page (the page with all the users on with the associated delete image)? So that the user clicks on the delete image, the php code will then delete the user (from their id) and then the list page should refresh to reflect those changes (ie. the list minus the deleted user).

 

This seems to be the biggest issue.

 

Thanks again for the quick reply mate.

Link to comment
Share on other sites

Thanks for the reply, I understand what technologies to use, its the correct usage of them that I am unsure of. Is the image tag the best way to do it i.e.

 


<INPUT TYPE="image" src="images/delete.gif" onclick="removeuser() " name="submit"> 

 

Then the remove user function by posting the userid in the querystring using javascript (AJAX)?

 

I will still have the problem of actually removing the user from the table.

Link to comment
Share on other sites

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.