Jump to content


Multiple deletes with an Image Submit button

  • Please log in to reply
2 replies to this topic

#1 Daniel.Conaghan1

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 12:12 PM

Hello All

This script has been knocking about the internet for years, It allows the user to select and delete multiple rows of the database from an html/php page using checkboxes. I have used it on many occasions, however I note that if I use an image rather then the submit button, I cannot set the variable $delete. Therefore the delete checker doesn't operate.

Is there a simple way to run this script with an image as a submit button?

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";


<table width="400" border="0" cellspacing="1" cellpadding="0">
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
// Check if delete button active, start this 
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
$result = mysql_query($sql);

// if successful redirect to delete_multiple.php 
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";

Thanks in advance


#2 .josh

  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 April 2006 - 05:51 PM

hidden field?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 massive

  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 29 April 2006 - 02:13 AM

Correct me if i'm wrong...are you trying to use an image button instead of the usual submit button? If thats the case try using CSS :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users