Linking an update button to a certain text field.
Posted: Mon Oct 02, 2006 6:35 am
I have a page that's a bank simulation which has 2 tables. The first table contains a unique ID to the customer, their name and address. The second table has the unique customer ID and the customers balance.
I have writen some code that places a text box and a "modify balance" button next to each entry but when I modify the balance it modifys every entry. Is there a possible way to do this so depending on which submit button the user presses it updates only a certain DB entry relating to that button, in a loop function?
The code I have so far is:
I have writen some code that places a text box and a "modify balance" button next to each entry but when I modify the balance it modifys every entry. Is there a possible way to do this so depending on which submit button the user presses it updates only a certain DB entry relating to that button, in a loop function?
The code I have so far is:
Code: Select all
$query = mysql_query("SELECT
b.custID, b.balance, c.id, c.fName, c.sName, c.addr
FROM
balance as b
LEFT JOIN
custDetails as c
ON
b.custID=c.id");
?><form method="post" action="join2.php"><?php
while ($results = mysql_fetch_array($query)) {
echo "<br><br>ID: ", $results['id'];
echo "<br>Name: ", $results['fName'], " ", $results['sName'];
echo "<br>Balance: ", $results['balance'];?>
<input type="text" name="balanceMod">
<input type="submit" value="Modify Balance">
<?php
} ?></form><?php
$modBalance = $_REQUEST["balanceMod"];
if (isset($_REQUEST["balanceMod"])) {
$insert = mysql_query("UPDATE balance SET balance='$modBalance'");
echo "Updated";
}