A link to deleted records via select checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

A link to deleted records via select checkboxes

Post by nite4000 »

I have this code that allows me to select any check box and hit the delete button and it removes the records from the database however i wanna make it a link instead OR make my compose and Delete a image but nothing I do works out.

Here is the code

Code: Select all

$id = $_POST['del'];
$count = count($id);

if($_POST['justdel_x']){
for ($i=0; $i<$count; $i++)
{
$sql = mysql_query("update table SET deleted='1' where id=$id[$i]");
}
}

Code: Select all

<input type="submit" value="Delete" id="justdel_x" name="justdel_x" />
as you see the button is a submit and i would like to make this all work either with link or image.


Someone please help me out i am sure the images can be done at least
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: A link to deleted records via select checkboxes

Post by fugix »

what are your results? without seeing your full form its hard to say what your problem is...also, why arent you using a delete clause instead of an update clause?
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

Re: A link to deleted records via select checkboxes

Post by emelianenko »

You could do that with Ajax and you would not even need to leave the page.

This is done via a select list, but you can do the same with checkboxes.


What you do is send to a php script, the id of the checkbox you checked and the php script takes that id, runs the sql query and that is it.

http://www.w3schools.com/php/php_ajax_database.asp
Post Reply