Hej
Vil høre om disse to loop kan skrives sammen?
foreach( $_POST['interval']['unit_weight_limit'] as $key => $value )
{
mysql_query ("UPDATE ".$prefix_db."shipment_units SET unit_weight_limit='$value' WHERE unit_id='$key'");
}
foreach( $_POST['interval']['unit_charge'] as $key => $value )
{
mysql_query ("UPDATE ".$prefix_db."shipment_units SET unit_charge='$value' WHERE unit_id='$key'");
}
$_POST kommer fra koden nedenfor
<form action="" method="POST" name="myform">
<p><input type="submit" name="update" value="Opdater"></p>
<table>
<tr><td>
<input type=\"text\" name=\"interval[unit_weight_limit][1]\" size=\"6\" value=\"".$unit['unit_weight_limit']."\"></td>
<td><input type=\"text\" name=\"interval[unit_charge][1]\" size=\"6\" value=\"".$unit['unit_charge']."\">
</td></tr>
<tr><td>
<input type=\"text\" name=\"interval[unit_weight_limit][2]\" size=\"6\" value=\"".$unit['unit_weight_limit']."\"></td>
<td><input type=\"text\" name=\"interval[unit_charge][2]\" size=\"6\" value=\"".$unit['unit_charge']."\">
</td></tr>
</table>
</form>