Jump to content

[SOLVED] date (help please)


phpretard

Recommended Posts

I kind of backed myself into a corner here.

 

I have stored dates in my DB like 04/06/2009

 

Now I need to edit via form.  The trick is geting the format stored into a select box.

 

So I gues the question is how can I turn this: 04/06/2009 back into this:

 


// MONTHS
<OPTION VALUE='04'>04 - Apr</OPTION> // THIS OPTION SHOULD BE THE DB VALUE
<OPTION VALUE="01">01 - Jan</OPTION>
<OPTION VALUE="02">02 - Feb</OPTION>
<OPTION VALUE="03">03 - Mar</OPTION>
<OPTION VALUE="04">04 - Apr</OPTION>
<OPTION VALUE="05">05 - May</OPTION>
<OPTION VALUE="06">06 - Jun</OPTION>
...and so on

// DAYS

<OPTION VALUE='06'>06</OPTION> // THIS OPTION SHOULD BE THE DB VALUE
<OPTION VALUE="01">01</OPTION>
<OPTION VALUE="02">02</OPTION>
<OPTION VALUE="03">03</OPTION>
<OPTION VALUE="04">04</OPTION>
<OPTION VALUE="05">05</OPTION>
<OPTION VALUE="06">06</OPTION>
<OPTION VALUE="07">07</OPTION>
<OPTION VALUE="08">08</OPTION>
...and so on

// YEARS
<option value="2009">2009</option> // THIS OPTION SHOULD BE THE DB VALUE
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>

 

 

Thanks for the help...I am stumped

Link to comment
https://forums.phpfreaks.com/topic/152754-solved-date-help-please/
Share on other sites

Simply explode at the /, then run a loop and check to see if the value of the checkbox is equal to that of the certain part of the date. If it is, add the selected='selected' part to it. Just try some things, it's really not that hard once you spell it out on paper. Give it a shot.

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.