Jump to content

Odd error with an IF statement....


monkeymade

Recommended Posts

I have a MySQL database set up to hold dates, and a drop down menu to enter a date, when a date is entered, I have it set up to auto select that date on the drop down menu so that you can see what its currently set at.  Here is my form code:

 

<select size="1" name="D7">
<option value="01" <?PHP IF ($fuel1 == 01) echo "selected"; ?>>Jan</option>
<option value="02" <?PHP IF ($fuel1 == 02) echo "selected"; ?>>Feb</option>
<option value="03" <?PHP IF ($fuel1 == 03) echo "selected"; ?>>March</option>
<option value="04" <?PHP IF ($fuel1 == 04) echo "selected"; ?>>April</option>
<option value="05" <?PHP IF ($fuel1 == 05) echo "selected"; ?>>May</option>
<option value="06" <?PHP IF ($fuel1 == 06) echo "selected"; ?>>June</option>
<option value="07" <?PHP IF ($fuel1 == 07) echo "selected"; ?>>July</option>
<option value="08" <?PHP IF ($fuel1 == 08) echo "selected"; ?>>Aug</option>
<option value="09" <?PHP IF ($fuel1 == 09) echo "selected"; ?>>Sept</option>
<option value="10" <?PHP IF ($fuel1 == 10) echo "selected"; ?>>Oct</option>
<option value="11" <?PHP IF ($fuel1 == 11) echo "selected"; ?>>Nov</option>
<option value="12" <?PHP IF ($fuel1 == 12) echo "selected"; ?>>Dec</option>
</select>

 

I have the exact same code on the page 5 times... I get the same error in all 5.

 

My MySQL for that date is

 

int 2 unsigned zerofill

 

There error I'm getting is, when I enter a date, it goes in perfectly every time into the MySQL, but the display will not enter "SELECTED" for August or September.  For those two months, it displays "Jan" even though the MySQL database still reflects 08 and 09 respectively.

 

I have put in a:

 

<?PHP echo $fuel1; ?>

 

to check the output, and it will display the 08 and 09, but its not working with the IF statement in the form.  I've developed a headache looking over this code for so long, and can't find any simple errors.  Anyone have any ideas on what I'm doing wrong here?

 

 

Link to comment
https://forums.phpfreaks.com/topic/194990-odd-error-with-an-if-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.