Hi guys,
currently i have a script where i use mysql_fetch_array() to diplay all the records and i have added an checkbox next to each record..
[CODE]
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td width=”24″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″> <input type=”checkbox” name=”remove” value=”<?= $row[‘code’] ?>”></font></p>
</td>
<td width=”28″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″> <?= $i++?></font></p>
</td>
<td width=”106″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″><?= $row[‘store’]?></font></p>
</td>
<td width=”168″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″><?= $row[’email’]?></font></p>
</td>
<td width=”170″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″> <?= $row[‘name’]?></font></p>
</td>
<td width=”112″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″> <?= $row[‘date’]?></font></p>
</td>
<td width=”87″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″> <?= $row[‘amount’]?></font></p>
</td>
<td width=”92″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″><?= $row[‘cc_status’]?></font></p>
</td>
<td width=”132″ height=”0″>
<p align=”center”><font face=”Arial” size=”2″><a href=”transactions2.php?status=approved”>Approved</a>
|<a href=”transactions2.php?status=rejected”> Rejected</a></font></p>
</td>
</tr>
<? } ?>
<tr>
<td width=”967″ height=”4″ colspan=”9″>
<p><font face=”Arial” size=”2″> <input type=”submit” name=”clean” value=”Remove”> |
Remove checked transaction record(s)</font></p>
</td>
</tr>
<tr>
<td width=”967″ colspan=”9″ bgcolor=”#FFCC66″>
<p><a href=”../main.php”><font face=”Arial” size=”2″>Back to main </font></a><font face=”Arial” size=”2″> |
Contact
</font><a href=”mailto:[email protected]”><font face=”Arial” size=”2″>person-in-charge</font></a></p>
</td>
</tr>
</table>
now my problem is, i wanna delete all the records that the checkbox beside the row is checked… i tried to use DELETE query but it seems like only able to delete one row.. if i check more than one checkbox, it doesn’t work.. if i use mysql_fetch_array() follow by the DELETE query, all my records will be removed even the records i didn’t select. can u guys give me an idea how to delete multiple records based to the checkbox..
[CODE]
<?php
session_start();
header (“cache-control/:private”);
include_once “include/db.php”;
include_once “include/check-session.php”;
$result = mysql_query(“SELECT * FROM transaction ORDER BY `date`”) or die(mysql_error());
$remove = mysql_QUERY(“DELETE FROM transaction WHERE `code`=’$remove'”) or die(mysql_error());
?>
please advise.