Selecting a record for deletion ..




Ive got a query that returns back the amount of records there are for a certain customer. It does this using the while($row3 = @mysql_fetch_array($result3)) statment.

I then echo the results to a table. I wanted to have a tick box next to each row it produces so that they can select any record and delete it.

How could I achieve this with just one submit button so the row they tick deletes from the database?

many thanks.
while ($row = mysql_fetch_object($result)) {
  echo "<input type=checkbox name='chk[]' /> $row->fieldname <br />"

//on the submit action page...
$lsit = implode (",", $_POST['chk']);
$sql = "delete from tablename where fieldname in ($list)";
This is what I got but it doesnt like it :

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

<table border="1" align="center" bordercolor="#C0C0C0"

Connect to Server
COnnect to DB

$query3 = "SELECT * FROM Customer_Shares WHERE CustomerID = '$customerid'";
$result3 = @mysql_query($query3);
if(!$result3) { die("Could not connect because ".mysql_error()); }

while($row3 = @mysql_fetch_array($result3))

$symbol_field = $row3["Symbol"];
$originalprice_field = $row3["OriginalPrice"];
$amount_field = $row3["Amount"];

echo '<tr><td>'.$symbol_field . '</td><td>'. $amount_field.'</td><td>' .$originalprice_field.'</td>';
echo '<td><input type = "checkbox" name="delete_user[]" value="$customerid"></td></tr>';



<tr><td></td><td></td><td></td><td><input type="submit" name="submit" value="Delete"></td></tr>



if (isset($_POST['submit']))

$query5 = "DELETE from Customer_Shares where $customerid in(".implode(', ', $_POST['delete_user']).")";

your code seems to be OK, please check the query if it is returning a result set.