DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

Chekbox delete option

By: rekha singh | 29 Jan 2010 1:26 am

Hello everybody,

I want to create a table that show MYSQL record and want to add  checkboxes so that user can select multiple or all record and can delete these selected records. But there is problem in deletion no record is deleted.plz plz help me.
Thanks in advance.

 

Comments



If u r beginner in php thn use following code(may be it is helpfull )

Else show ur code

<form action="delete. php" method = "POST">
</table>
<?php
$con = mysql_connect( "localhost" ,"mysql_user" ,"mysql_pwd" );
if (!$con)
  {
  die('Could not connect: ' . mysql_error( ));
  }
mysql_select_ db("my_db" , $con);

$sql = "SELECT * FROM Person";
$rs = mysql_query( $sql,$con) ;
while($row=mysql_ fetch_array( $rs)){        
?>

<tr>
<td><input name="delete_ id" type="checkbox" value="<?=$row[ "id"]?>"> </td>
  <td><?=$row[ colom_name_ 1]?></td>
  <td><?=$row[ colom_name_ 2]?></td>
  <td><?=$row[ colom_name_ 3]?></td>
</tr>
<? } ?>
<tr>
<td><input name="Delete" type="submit" ></td>
</tr>
</table>
</form>

------------ --------- --------- --------- --

delete.php:

<?php
$con = mysql_connect( "localhost" ,"mysql_user" ,"mysql_pwd" );
if (!$con)
  {
  die('Could not connect: ' . mysql_error( ));
  }

mysql_select_ db("my_db" , $con);

mysql_query( "DELETE FROM table_name WHERE colom_name=" .$_POST[' delete_id' ].");

mysql_close( $con);
 

By: rekha singh | 29 Jan 2010

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move