Page 1 of 1

A link to deleted records via select checkboxes

Posted: Tue May 31, 2011 7:53 am
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

Re: A link to deleted records via select checkboxes

Posted: Tue May 31, 2011 12:17 pm
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?

Re: A link to deleted records via select checkboxes

Posted: Wed Jun 01, 2011 5:14 am
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