Page 1 of 1

Drop Down Menu

Posted: Fri Jul 16, 2004 9:04 pm
by SidewinderX
Hello, I guess im trying to populate a drop down menu with a variable, the script I wrote is pretty simple

<?php
for ($i = 8; $i <=64; $i+=2){
print "$i <br>\n";
}
?>

Which of course starts at 8 and goes to 64 by 2 in other words 8, 10, 12, 14....and so on

Now my question is how do I put those numbers ($i) into a drop down menu. Ive tried all sorts of syntax but usually it either dosent work at all, prints all the numbers on one line, or prints '66' only.
Any help is appreciated.

Thanks,
~~~Sidewinder~~~

Posted: Fri Jul 16, 2004 9:09 pm
by feyd

Code: Select all

<?php

$output = '<select name="something">';
for($i = 8; $i <= 64; $i += 2)
{
  $output .= '<option value="'.$i.'">'.$i.'</option>';
}
$output .= '</select>';

echo $output;

?>