I have a page where I enter updates to multiple records (up to a hundred) on the same page. The entries are put into an array which is passed by post to a processing page which uses PHP. This works okay for text box entries. However, I want to put a checkbox for each entry so I can pass a flag to the database. I've tried using an array of checkboxes but it doesn't seem to work.
This is the code:
This is the section of the code that collects and sends the data. The 'NCR[]' and 'Disq[]' are what I trying to pass to the processing page via the 'redirect' page. The PlayerNo, Handicap and Scores arrays work okay.
It uses the following code to pass from the 'redirect' to the processing page. This a section of the 'redirect.php' page
When it gets to the processing page the first part is the this-
I put the loop in to show me what was coming across into the $disqArray, which is basically nothing.
Any suggestions.
This is the code:
Code:
<form action="redirect.php" method="POST">
<center><table vertical-align: top>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td align="center">NCR</td>
<td> </td>
<td align="center">Disq</td>
</tr>
<?
while ($row = mysqli_fetch_assoc($res))
{
$playerId = $row['PlayerNo'];
$handicap = $row['Handicap'];
?>
<tr>
<td><input type="hidden" name="playerNo[]" value="<? echo $playerId ?>" /></td>
</tr>
<tr>
<td><input type="hidden" name="handicap[]" value="<? echo $handicap ?>" /></td>
</tr>
<tr>
<td><?php echo $row['PreferredName']." ".$row['Surname']." "
.$row['StateRep']." ".$row['Handicap'] . "\n"; ?></td>
<td> </td>
<td><input type="text" name="score[]" size="4" ></td>
<td> </td>
<td><input type="checkbox" name="NCR[]" value="1" align="center" /></td>
<td> </td>
<td><input type="checkbox" name="disq[]" value="1" align="center" /></td>
</tr>
<?php
}
?>
</table></center>
<br /><br />
<center><input type="submit" name="addScores" value="Save scores" /></center>
<br /><br />
<center><input type="submit" name="addScores" value="Cancel" /></center>
</form>
It uses the following code to pass from the 'redirect' to the processing page. This a section of the 'redirect.php' page
PHP:
elseif (trim($_POST['addScores']) == 'Save scores')
{
$_SESSION["plNumber"] = $_POST['playerNo'];
$_SESSION["handicap"] = $_POST['handicap'];
$_SESSION["score"] = $_POST['score'];
$_SESSION["ncr"] = $_POST['NCR'];
$_SESSION["disq"] = $_POST['disq'];
header("location: processScores.php");
exit;
}
When it gets to the processing page the first part is the this-
PHP:
session_start();
$plNumber = $_SESSION["plNumber"];
$scores = $_SESSION['score'];
$scoreDay = $_SESSION['scoreDay'];
$scoreTime = $_SESSION['scoreTime'];
$handicap = $_SESSION['handicap'];
$ncrArray = $_SESSION['ncr'];
$disqArray = $_SESSION['disq'];
$x = count($plNumber);
for($i=0; $i < $x; $i++)
{
echo("Disq = ".$disqArray[$i] . "\n");
}
I put the loop in to show me what was coming across into the $disqArray, which is basically nothing.
Any suggestions.