I want to diplay comments and in each comment there will be a checkbox:
Now is there anybody who can tell me how use them in php so that when i select
forexample 5checkboxes containing comment each,i will be able to DELETE them All
at the same time.?

You can use a code like the following:

<form method="post">
<input type="checkbox" name="ids[]" value="1" />
<input type="checkbox" name="ids[]" value="2" />
<input type="checkbox" name="ids[]" value="3" />
<input type="checkbox" name="ids[]" value="4" />
<input type="submit" value="Delete" />
if (isset($_POST['ids'])) {

If you place the record ID in each checkbox value, you will get them as an array that you can easily use to create your DELETE statement.

if you're using a database, you could use something like this.

this script is for a postgre database, for mysql replace "pg_" with "mysql_"
//connection here
if(count($_POST) > 0)
		$commentpks = "";
		foreach($_POST['chkCommments'] as $commentpk)
			$commentpks .= $commentpk . ", ";
		$commentpks = substr($commentpks, 0, -2); //delete the final ", "
		$query = "delete from comments where commentpk in(" . $commentpks . ")";

$query = "select commentpk, comment from comments where commenttype = 'applies to this page'";
$result = pg_query($query);
$total = pg_num_rows($result);

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<form action="<? echo $_SERVER['REQUEST_URI']; ?>" method="post">
	for($i = 0; $i < $total; $i++)
    	<input type="checkbox" value="<? echo pg_result($result, $i, "commentpk"); ?>" />&nbsp;<? echo pg_result($result, $i, "comment"); ?><br />
This article has been dead for over six months. Start a new discussion instead.