Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.