Hi
I've been trying to debug this. If any of the checkboxes are ticked - instead of them retaining their position in the array, they are moving to beginning of the array.
http://www.hollysden.co.uk/test.php
<?
$sent = $_POST['sent'];
$title = $_POST['title'];
$country_code = $_POST['country_code'];
$rate1 = $_POST['rate1'];
$rate2 = $_POST['rate2'];
$rate3 = $_POST['rate3'];
$allowed = $_POST['allowed'];
include("connect.php");
$i=0;
if ($sent==true)
{
$result = mysql_query("SELECT * FROM shipping_rates ORDER BY id");
while ($row = mysql_fetch_row($result))
{
echo "row: $row[0]<br />i: $i<br />rate 1: $rate1[$i]<br />allowed: $allowed[$i]<br />";
$i++;
}
}
?>
<form action="shipping.php" method="post">
<input type="hidden" name="sent" value="true" />
<table cellpadding="3" cellspacing="0" width="100%" border="1" bordercolor="#E7D6D5">
<tr bgcolor="#E7D6D5"><th>Country Code</th><th >Rate 1</th><th>Rate 2</th><th>Rate 3</th><th>Country</th><th>Allow Shipping</th></tr>
<?
$result = mysql_query("SELECT * FROM shipping_rates ORDER BY id");
while ($row = mysql_fetch_row($result))
{
$i++;
if ($i%2)
echo "<tr bgcolor=\"#F9F9F9\">";
else
echo "<tr>";
echo"<td>$row[0] $row[1]<input type=\"hidden\" name=\"country_code[]\" value=\"$row[1]\" /></td>
<td align=\"center\"><input name=\"rate1[]\" type=\"text\" value=\"$row[2]\" size=\"8\" /></td>
<td align=\"center\"><input name=\"rate2[]\" type=\"text\" value=\"$row[3]\" size=\"8\" /></td>
<td align=\"center\"><input name=\"rate3[]\" type=\"text\" value=\"$row[4]\" size=\"8\" /></td>
<td>$row[5] $row[6]</td>";
if ($row[5]=="ON")
echo "<td align=\"center\"><input name=\"allowed[]\" type=\"checkbox\" value=\"ON\" checked=\"checked\" /></td></tr>";
else
echo "<td align=\"center\"><input name=\"allowed[]\" type=\"checkbox\" value=\"ON\" /></td></tr>";
}
?>
</table>
<hr />
<input type="submit" value="Update Shipping Rates" />
</form>