Hi everyone,
I'm currently trying to update one field for multiple rows in an SQL table using one Submit button. Is this possible? If so, does anyone have a sample line of code that would do the job?
At present, this is my table that I have displaying the editable "Percentage" field. The idea is that when the percentage changes are made, the amount claimed field will update itself on refresh.
echo"
<form action=\"edit.php?action=amend_variation\" name=\"frmEdit\" method=\"post\">
<table width=\"650\">
<tr><td width=\"50\" bgcolor=\"#CCCCCC\" valign=\"top\"><b>VO#</b></td><td width=\"200\" bgcolor=\"#CCCCCC\" valign=\"top\"><b>Details</b></td><td width=\"100\" bgcolor=\"#CCCCCC\" valign=\"top\"><b>Inst By</b></td><td bgcolor=\"#CCCCCC\" valign=\"top\" align=\"center\"><b>Amount (£)</b></td><td bgcolor=\"#CCCCCC\" valign=\"top\"align=\"center\"><b>Claimed (%)</b></td><td bgcolor=\"#CCCCCC\" valign=\"top\" align=\"center\"><b>Claimed (£)</b></td></tr>
";
$get_variations = mysql_query("
SELECT V.variation_num as num,
V.variation_detail as detail,
V.variation_ins as ins,
V.variation_id as vid,
V.variation_percent as percent,
V.variation_cost as cost,
(V.variation_percent / 100) * V.variation_cost as outstanding
FROM val_contracts C, val_variations V
WHERE C.contract_id = '".$_GET["con"]."'
AND C.contract_id = V.variation_con
ORDER by V.variation_num ASC
",$objConnect);
while($data = mysql_fetch_array($get_variations))
{
echo"
<tr><td valign=\"top\">$data[num]</td><td valign=\"top\">$data[detail]</td><td valign=\"top\">$data[ins]</td><td align=\"center\" valign=\"top\">";
$cost = number_format($data['cost'],2);
echo"$cost</td><td align=\"center\" valign=\"top\">
<input type=\"text\" name=\"percent\" size=\"5\" value=\"$data[percent]\">%</td><td align=\"center\" valign=\"top\">
<input type=\"hidden\" name=\"vid\" value=\"$data[vid]\">";
$outstanding = number_format($data['outstanding'],2);
echo"$outstanding</td></tr>";
}
echo"</table><br><input type=\"submit\" name=\"submit\" value=\"Submit\"></form>";
What I want to know is, when that Submit button is clicked, how do I ensure that each of the percent fields are updated at the same time?
I've added a screenshot to show what the form looks like. Any help would be greatly appreciated.