stkoontz
asked on
Input loop always chooses last option
I'm pulling data from a table using PHP. The data goes into a form with inputs. The data in the form is good on the page, but when I click the 'submit' button, the only data that's posted is the last record.
I uploaded a test page here...
http://testregister.cenational.org/admin/commitment/test.php
that goes to a page that echos the POST. It must be something simple I'm missing, so any ideas are appreciated.
Here's the code of test.php
Receiving page code
I uploaded a test page here...
http://testregister.cenational.org/admin/commitment/test.php
that goes to a page that echos the POST. It must be something simple I'm missing, so any ideas are appreciated.
Here's the code of test.php
<?php
$id_commitment='testCommit';
$id_event='mo14420';
//Store registrants into array_registrations
try {
$qry_registrants = new PDO("mysql:host=$xxxxx=$xxxxx",$xxxxx,$xxxxx);
$sth = $qry_registrants->prepare("SELECT
table1.fm_lname,
table1.fm_fname,
table1.id_family_member,
table2.f_city,
table2.f_state
FROM
table1, table2, table3
WHERE
table2.id_family=table1.id_family AND
table3.id_family_member=table1.id_family_member AND
table3.id_event='$id_event'
");
$sth->execute();
$qry_registrations = null;
}
catch (PDOException $e) {
print "Error! Please email steve@cenational.org";
die();
}
/* Fetch all of the remaining rows in the result set */
$array_registrations = $sth->fetchAll(PDO::FETCH_ASSOC);
?>
<form action="test_code.php" method="post" enctype="application/x-www-form-urlencoded" id="form1">
<table border="1" align="center">
<tr>
<td colspan="3" align="center"><h2> </h2></td>
</tr>
<tr>
<td>ID Family Member</td>
<td>Record Commitment</td>
</tr>
<?php
$x=1;
foreach ($array_registrations as $sub_registrations) {
$id_family_member_button=$sub_registrations['id_family_member'];
?>
<tr>
<td><?php echo $sub_registrations['id_family_member'];?></td>
<td align="center">
<input type="text" name="id_event" id="id_event" value="<?php echo $id_event;?>" />
<input type="text" name="id_family_member" id="id_family_member" value="<?php echo $id_family_member_button;?>" />
<input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<?php } ?>
</table>
</form>
Receiving page code
echo "<pre>";
var_export($_POST);
echo "</pre>";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Steve