I have a form that queries my data table and pulls up a varying number of inputs depending on how many rows are in the table.
For example, if there were 5 people's names in a phone book, the form queries the database, sees that there are 5 entries, displays all 5 names, and then displays an input asking for each person's age.
This data is going to be further processed, so it needs to be thrown into a php variable.
Ordinarily, if I'm processing a form, the processing script grabs data in the following way... (using the above example)
$age = $_POST['age'];
In my dynamic form, I created a counter string for the 'age' input id's. In other words, a form with 5 entries in the address book will have 5 age input id's -- age1, age2, age3, age4, and age5.
Now, however, I'm stumped. I'm trying to write my processing script and I have no idea how to post my form data into variables. I have to find a way to generate unique variable names for each form field. I tried this...
<?php
$count= $_POST['count'];
//this is a hidden variable posted by my form, telling me how many rows are in my table.
$ticker=0;
//this starts my variable counter at 0
do {
$ticker = $ticker + 1;
$age'$ticker' = $_POST['age'$ticker''];
while ($ticker <= $count); ?>;
This gives me an unexpected T_CONSTANT_ENCAPSED_STRING in the "$id'$ticker' = $_POST['alarmtype'$ticker'];" line. Obviously, this isn't legal syntax. I'm not advanced enough to know if there's a simpler way to do this.
Help?
Thanks,
Karen