-1

hi,
i'm using menu for displaying birth month of user...
i hav added 12 entries denoting 12 months of a year.
items and thier values are...
Item Value
Jan 1
Feb 2
... .
... .
Nov 11
Dec 12

the values are stored in Database.

Problem is viewing the deatails in editing page.
Instead showing 12 items, it shows 13 items (12 items in menu+itemselected)

say, Mar... it shows march twice & other items once...

Help to solve my problem...

2
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by nadnakinam
0
<label>
                    <select name="month" id="month">
                    <OPTION SELECTED>
	      <?php echo $this_month;?>
	      <option value="1">Jan</option>
                      <option value="2">Feb</option>
                      <option value="3">Mar</option>
                      <option value="4">Apr</option>
                      <option value="5">May</option>
                      <option value="6">Jun</option>
                      <option value="7">Jul</option>
                      <option value="8">Aug</option>
                      <option value="9">Sep</option>
                      <option value="10">Oct</option>
                      <option value="11">Nov</option>
                      <option value="12">Dec</option>
                    </select>
                  </label>
0

The echo is the 13th option. Try this:

<select name="month" id="month">
	<option value="1" <?php echo if ($this_month == 'Jan') echo 'selected'; ?>>Jan</option>
	<option value="2" <?php echo if ($this_month == 'Feb') echo 'selected'; ?>>Feb</option>
	<option value="3" <?php echo if ($this_month == 'Mar') echo 'selected'; ?>>Mar</option>
	<option value="4" <?php echo if ($this_month == 'Apr') echo 'selected'; ?>>Apr</option>
	// etc.
</select>

A better way would be to use a loop.

0
<select name="month" id="month">
    <option value="1" <?php echo if ($this_month == 'Jan') echo 'selected'; ?>>Jan</option>	
    <option value="2" <?php echo if ($this_month == 'Feb') echo 'selected'; ?>>Feb</option>	
    <option value="3" <?php echo if ($this_month == 'Mar') echo 'selected'; ?>>Mar</option>	
    <option value="4" <?php echo if ($this_month == 'Apr') echo 'selected'; ?>>Apr</option>
    <option value="5" <?php echo if ($this_month == 'May') echo 'selected'; ?>>May</option>	
    <option value="6" <?php echo if ($this_month == 'Jun') echo 'selected'; ?>>Jun</option>	
    <option value="7" <?php echo if ($this_month == 'Jul') echo 'selected'; ?>>Jul</option>	
    <option value="8" <?php echo if ($this_month == 'Aug') echo 'selected'; ?>>Aug</option>
    <option value="9" <?php echo if ($this_month == 'Sep') echo 'selected'; ?>>Sep</option>	
    <option value="10" <?php echo if ($this_month == 'Oct') echo 'selected'; ?>>Oct</option>	
    <option value="11" <?php echo if ($this_month == 'Nov') echo 'selected'; ?>>Nov</option>	
    <option value="12" <?php echo if ($this_month == 'Dec') echo 'selected'; ?>>Dec</option>
                    </select>

Parse error: parse error in C:\wamp\www\28_09_pm_new\profile edit.php on line 932 (here line 2)

0
<select name="month" id="month">	<option value="1" <?php echo if ($this_month == 'Jan') echo 'selected'; ?>>Jan</option>	<option value="2" <?php if ($this_month == 'Feb') echo 'selected'; ?>>Feb</option>	<option value="3" <?php echo if ($this_month == 'Mar') echo 'selected'; ?>>Mar</option>	<option value="4" <?php echo if ($this_month == 'Apr') echo 'selected'; ?>>Apr</option>	// etc.</select><select name="month" id="month">
	<option value="1" <?php if ($this_month == 'Jan') echo 'selected'; ?>>Jan</option>
	<option value="2" <?php if ($this_month == 'Feb') echo 'selected'; ?>>Feb</option>
	<option value="3" <?php if ($this_month == 'Mar') echo 'selected'; ?>>Mar</option>
	<option value="4" <?php if ($this_month == 'Apr') echo 'selected'; ?>>Apr</option>
	// etc.
</select>

echo after <php is not needed...
stated as above...

Thanx Pritaeas...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.