FOR, FOREACH, and Input Box Names
| From: | Guru Geek | Date: | Fri, 25 Apr 2003 20:10:04 +0000 |
| Subject: | FOR, FOREACH, and Input Box Names | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-145310@lists.php.net to get a copy of this message | ||
I'm creating a table. The number of rows is based on a previous student
entry. Students must submit how many courses they are currently taking
(numberCourses). Once they submit that value, I want to draw a table.
The amount of rows in this table must be equal to the amount of courses
being taken. Taking 3 courses then you'll get a table with 3 rows.
Each row will have two input boxes (creditBox and estimatedGrade). The
rest of the program will work with these two values extensively. How
can I individualize the name of each creditBox? That is to say, how can
I keep the value entered inside the creditBox in row one seperate from
the value entered inside the creditBox on line 4 (assuming there is a
line 4). I use a FOR statement to draw my table based on the amount of
courses being taken.
Here's my code:
for ($boxCreator=0; $boxCreator < $numberCourses; $boxCreator++)
{
echo '
<tr>
<td align="center">Course</td>
<td align="center"><input type="text" name="creditBox"
size="2"></td>
<td align="center"><input type="text"
name="estimatedGrade"
size="2"></td>
</tr>';
}
Thanks in advance,
Roger