In the following code sample, I have 5 variables set to people's names.
I then "Echo" all the HTML forms tags.
For the forms "<option.. =" tag I have a loop to place the correct number of names in the form.
This works fine as long as I just place text in the form.
What I want to do is put the PHP variable $N1 - $N5 in the form.
I also need to increment the "value=" tag with the $i counter.
Any help is welcome,
Jon
<?php
Echo '<html>';
Echo '<body>';
$N1 = "William H. Smith";
$N2 = "Stanley E. Smith";
$N3 = "Florence P. Smith";
$N4 = "Jon F. Smith";
$N5 = "Jon G. Smith";
$Name_Count = 5;
Echo '<form action="">';
Echo '<select name="People" size="5">';
$i=0;
while ($i < $Name_Count)
{
Echo '<option value="P1-5">one - five</option>';
$i++;
}
Echo '</select>';
Echo '<p>';
Echo '<input type="submit" />';
Echo '</p>';
Echo '</form>';
Echo '</body>';
Echo '</html>';
?>
Edited by Jordan, 04 November 2008 - 02:10 PM.
Added php tags


Sign In
Create Account


Back to top









