EEK!
Weird problem here:
This script works, kinda..
it only updates the first record with a checkbox unless I check ALL of the ones above each other.
(so if I check only the second box, it won't work, and I echoed to see what it was doing and it is only getting the first record.)
However, if I check both the first AND second record, it works fine..
and the first one by itself works fine..
Any help woudl be appreciated..
(oh yeah, and I have to REFRESH the page at each time as well.)
here is 'test'php'
echo "<form method='post' name='test[]' action='test.php'>";
$db = mysql_connect ("localhost", "user", "password");
mysql_select_db ("database", $db);
$sql9 = "select empnumber, SEC_LVL from employees ";
$res = mysql_query($sql9);
echo "<table border = '1'>";
echo "<TR><TD>Check</TD><TD>SEC_LVL</TD><TD>Empnumber</TD></TR><TR>";
while($row=mysql_fetch_array($res))
{
echo "<TD><input type='checkbox' name='SEC_LVLC[]'></TD>";
echo "<TD><input type='text' name='SEC_LVL[]' value='".$row[SEC_LVL]."'></TD>";
echo "<TD>".$row[empnumber]."</TD><input type='hidden' name='empnumber[]' value='".$row[empnumber]."'></TR>";
}
echo "</table>";
for($i=0; $i<count($SEC_LVLC); $i++){
$query = "UPDATE employees SET SEC_LVL='".$SEC_LVL[$i]."' WHERE empnumber='".$empnumber[$i]."' ";
$res = mysql_query ($query) or die("Couldn't upddate database.<BR>empnumber=".$empnumber[$i]."<BR>SEC_LVL=".$SEC_LVL[$i]."<BR>");
echo "Empnumber=".$empnumber[$i]."<BR>";
echo "SEC_LVL=".$SEC_LVL[$i]."<BR>";
echo "SEC_LVLC=".$SEC_LVLC[$i]."<BR>";
echo "<hr>";
$tmp = "<meta http-equiv=\"refresh\" content=\"0; URL=test.php\">";
echo $tmp;
//exit();
}
mysql_close ($db);
this code may be useful to others as well..
(but you might want to wait until I get it fixed first though..hehe.. Will post here when it's done..)
Thanx,
Matt