acctman Posted October 16, 2008 Share Posted October 16, 2008 why I run this array code below the month names show correctly but the number values are not correct. $_SESSION['month'] is equal to "2" for every month the value is shown as 2, why is this happening. <?php $months = array( 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'Octobner', 11 => 'November', 12 => 'December' ); foreach ($months as $month_id => $month_name) { $selected = ($_SESSION['month'] == $month_id) ?' selected="selected"':''; echo "<option value=\"$_SESSION['userid']\" $selected>$month_name</option>\n"; } ?> this is what is being printed in the html. its repeating the selected value of "2" <SPAN class=label>Birthday:</SPAN> <SPAN class=normal><SELECT name=add[month]><OPTION value=2>January</OPTION> <OPTION selected value=2>February</OPTION> <OPTION value=2>March</OPTION> <OPTION value=2>April</OPTION> <OPTION value=2>May</OPTION> <OPTION value=2>June</OPTION> <OPTION value=2>July</OPTION> <OPTION value=2>August</OPTION> <OPTION value=2>September</OPTION> <OPTION value=2>Octobner</OPTION> <OPTION value=2>November</OPTION> <OPTION value=2>December</OPTION></SELECT> </SPAN> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 16, 2008 Share Posted October 16, 2008 You're using $_SESSION['userid'] and not $_SESSION['month']... Quote Link to comment Share on other sites More sharing options...
acctman Posted October 16, 2008 Author Share Posted October 16, 2008 You're using $_SESSION['userid'] and not $_SESSION['month']... sorry that was a typo... it does have $_SESSION['month'] in the original coding. I'm still having that problem of the month values not showing properly Quote Link to comment Share on other sites More sharing options...
.josh Posted October 16, 2008 Share Posted October 16, 2008 shouldn't you be doing value="$month_id" ? Quote Link to comment Share on other sites More sharing options...
acctman Posted October 16, 2008 Author Share Posted October 16, 2008 shouldn't you be doing value="$month_id" ? you're right... thanks =) Quote Link to comment 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.