Mega Code Archive

 
Categories / Php / Form
 

Generating a dynamic pull-down menu

<? if ($site != "") :     header("Location: http://$site");     exit; else : ?> <html> <head> <title></title> </head> <body> <? $favsites = array ("www.rntsoft.com","www.yahoo.com","www.ms.com","www.php.com"); ?> <form action = "index.php" method="post"> <select name="site"> <option value = "">Choose a site: <? $x = 0; while ( $x < sizeof ($favsites) ) :           print "<option value='$favsites[$x]'>$favsites[$x]";           $x++; endwhile; ?> </select> <input type="submit" value="go!"> </form> <? endif; ?>