This is probably very simple, but unfortunately since I'm a n00b I can't figure out how to do this.
I have a form http://phpbuilder.com/board/attachment.php?attachmentid=2980&stc=1&d=1174351965 generated by:
$select = "SELECT workerName, jobDone FROM worker";
$selectResult = mysql_query($select,$link)
or die("Selection of Workers Failed");
$workerName = "";
$jobDone = "";
$count = 1;
echo "<table width='50%' border='0' cellspacing='1' align='left'>";
while ($row = mysql_fetch_array($selectResult)) {
$worker = $row["workerName"];
$job = $row["jobDone"];
echo "<tr>";
echo "<th scope='row' align='left'>".$worker."</th>";
echo "<td><input type='text' name=$count value=$job
maxlength=8 width='10%'></input></td>";
echo "<tr>";
$count = $count + 1;
}
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='Submit'/></td></tr>";
echo "</table>";
Basically, the code goes through the "WORKER" table in the database, obtain and display the job count for each worker. I want to be able to change the values (job count) in the text fields, and once the "Submit" button is clicked, it should call "form-reset.php" and update the "WORKER" table accordingly.
Problem, I'm not entire sure how to code the "form-reset.php" -- i.e. I don't know how to get the values from the text fields properly (if that makes sense).
Any suggestions would be greatly appreciated 😃.
Edit: sorry I should've made it more clear.
In form-reset.php, I tried to do something like
$jobDone = $_POST["jobDone"];
$workerID = $_POST["workerID"];
$link = mysql_connect("", "fred", "jones") or die("Could not connect");
if ($link == false){ // if fails to connect
echo mysql_errno().": ".mysql_error();
exit;
}
mysql_select_db("helpIT2") or die("Could not select database");
$i = 1;
$updateStatus = mysql_query($update,$link) or die("Update job Failed");
while($i <= count($jobDone)) {
$update = "UPDATE worker SET jobDone = '".$jobDone[$i]."' WHERE workerID = ".$i;
echo $update;
$i++;
$updateStatus = mysql_query($update,$link) or die("Update job Failed");
}
It's the loop part that I'm not sure how to implement. I think PHP arrays starts indexing at 0, but "workerID" doesn't start at 0.