I’m trying to pass a text value field over to the next page for every checkbox selected, but I’m only getting the last text fields value, example:
checkbox textfield
selected ABCD
selected ABCDE
I am only getting back the ABCDE every time
page1.php
echo "<td width='10px'><input name='question[$rowid][]' type='checkbox' value='1' /></td>";
echo "<td width='230px'><input name='newname' type='text' value='$certn'/></td>";
page2.php
foreach ($_POST['question'] as $key => $ans) {
$nn = $_POST['newname'];
echo $key . $nn;
echo "</br>";
}
Help will be greatly appreciated
It’s a little hard to work out exactly what you’re doing here but I think your statement
I'm only getting the last text fields valueindicates your problem – you have multiple fields with the same name. If you do this and don’t make them into an array ([]), you will only get the last value on the page.I think you want something more like this:
Page 1:
Page 2: