janek211 Posted August 4, 2008 Share Posted August 4, 2008 I am beginner, I am trying to use foreach to display some things in a select, but its always showing the highest value, why? Please help me <html> <head> <body> <form action="form5.php" method="post"> <? $days= array (1=>'m','n','k'); echo '<select name="day">'; foreach ($days as $key => $value); {echo "<option value=\"$key\">$value</option>";} echo '</select>'; ?> </form> <body> <head> <html> Quote Link to comment https://forums.phpfreaks.com/topic/118007-problems-with-foreach-and-form-select/ Share on other sites More sharing options...
sasa Posted August 4, 2008 Share Posted August 4, 2008 remove ; in foreach line <html> <head> <body> <form action="form5.php" method="post"> <? $days= array (1=>'m','n','k'); echo '<select name="day">'; foreach ($days as $key => $value) //; <-- remove this {echo "<option value=\"$key\">$value</option>";} echo '</select>'; ?> </form> <body> <head> <html> Quote Link to comment https://forums.phpfreaks.com/topic/118007-problems-with-foreach-and-form-select/#findComment-607225 Share on other sites More sharing options...
janek211 Posted August 5, 2008 Author Share Posted August 5, 2008 Wow so easy! Thank u a lot, now everything works CLOSE please Quote Link to comment https://forums.phpfreaks.com/topic/118007-problems-with-foreach-and-form-select/#findComment-608322 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.