Hi,
I'm writing a portion of a size that allows users to custom configure a product.
One of our categories is "Video," and we give users a choice of including up to 8 diffent video devices.
Because (a) these 8 menus are all the same and (b) we may change the number in the future when new hardware allows us to support more, I wanted to generate the menus using a while loop.
So what I have is:
$i = 1;
while ($i <= 8) { ?>
<tr>
<td width="20"> </td>
<td><font face="Arial, Helvetica, sans-serif" size="2">Video 2:</font></td>
<td>
<input type="text" name="in_vid<? echo "$i"; ?>qt" value="<? echo "$in_vid_2_qt"; ?>" size="1" maxchar="1">
<select name="in_vid_2">
<? displaylist_b("Video In", "0", $in_vid$i, $in_vid$i_qt);?>
</select>
</td>
</tr>
<?
$i++;
}
You will, of course, notice the obvious problem with what I am doing. The above code is for after the page has been submitted once (user can submit, configure, resubmit, and so on)- so there are existing values which must be displayed. Now, these existing values for video in have variable names such as $in_vid_1, $in_vid_2, and so on. To reference them in this function, I need to essentially do $in_vid_$i each time, which would not be valid. I suppose this could be fixed with arrays (define them as $in_vid[$i] ). Is this the best/only way? It's about all I can think of. I'm also not too clear on what's required to define it initially.