Multiple buttons to do different actions
Posted: Mon Oct 02, 2006 6:05 pm
I have made a virtual banking system where so far a table displays a unique customer ID, name and balance. I have a text box with a button next to it to update the customers balance and now I want to expand this to add a button to delete a customer. How is it possible to do 1 action if a certain buttons is pressed and another action if another is pressed.
Here's what it looks like so you get a clear idea
http://stesbox.co.uk/php/vbank/vbank.php
The code is:
Stephen,
Here's what it looks like so you get a clear idea
http://stesbox.co.uk/php/vbank/vbank.php
The code is:
Code: Select all
$modBalance = $_REQUEST["balanceMod"];
$boxID = $_REQUEST["userid"];
if (isset($_REQUEST["balanceMod"])) {
$insert = mysql_query("UPDATE balance SET balance='$modBalance' WHERE custID='$boxID'");
}
$query = mysql_query("SELECT
b.custID, b.balance, c.id, c.fName, c.sName, c.address
FROM
balance as b
LEFT JOIN
custDetails as c
ON
b.custID = c.id");
?>
<center>
<table border="1" bgcolor="black">
<tr>
<th><font color="white"> ID </th> <th>><font color="white"> Name </th> <th>><font color="white"> Balance </th> <th>><font color
</tr>
<?php
while ($results = mysql_fetch_array($query)) { ?>
<form method="post" action="vbank.php">
<tr>
<td bgcolor="grey"><font color="white"><?php echo "<br><b>", $results['id']; ?></td>
<td bgcolor="grey"><font color="white"><?php echo "</b><br>", $results['fName']; ?>
<font color="white"><?php echo "<br>", $results['sName']; ?></td>
<td bgcolor="grey"><font color="white"><?php echo "<br>\$", $results['balance']; ?></td>
<input type="hidden" name="userid" value="<?php echo $results['id']; ?>">
<td bgcolor="grey"><font color="white">$<input type="text" name="balanceMod"></td>
<td bgcolor="grey"><input type="submit" value="Modify Balance"></td>
<td bgcolor="grey"><input type="submit" value="Delete Customer"></td>
</form>
<?php
}
?>
</table>
<br>
<center><table border="1" bgcolor="black">
<tr><th>
<form method="post" action="vbankAdd.php">
<center><input type="submit" value="Add"><br><font color="white"> a customer
</form>
</th></tr>
</table>