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> 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> 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 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
Archived
This topic is now archived and is closed to further replies.