note 50319 deleted from function.eval by sniper
| From: | sniper@php.net | Date: | Thu, 29 Dec 2005 09:15:15 +0000 |
| Subject: | note 50319 deleted from function.eval by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100907@lists.php.net to get a copy of this message | ||
Note Submitter: Geoff Eby
----
I couldn't find an example of what I wanted to do, which was dynamically create and handle
enumerated variables from a form, so here it is in simplified form:
<?php
echo("<table>");
$counter=0;
for ($a=0;$a<count($timeslots);$a++) {
echo("<tr>");
for ($i=0;$i<3;$i++) {
$counter++;
$fieldwithcounter="fieldname$counter";
$var1=$_POST[$fieldwithcounter];
$nextfield="second$counter";
$var2=$_POST[$nextfield];
$thirdfield="lastfield$counter";
$var3=$_POST[$thirdfield];
eval("\$grouprow$a.=\"$var1^^$var2^^$var3^^$var4\";");
// creates $grouprow0, $grouprow1, $grouprow2, ...
echo("<td>
First field
<input type='text' name='fieldname$counter'
value='$var1'><br>
Second field
<input type='text' name='second$counter'
value='$var2'><br>
Last field
<input type='text' name='lastfield$counter'
value='$var3'>
</td>");
}
echo("</tr>");
}
echo("</table>");
?>