phpretard Posted April 6, 2009 Share Posted April 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/152754-solved-date-help-please/ Share on other sites More sharing options...
gizmola Posted April 6, 2009 Share Posted April 6, 2009 You might try explode. Quote Link to comment https://forums.phpfreaks.com/topic/152754-solved-date-help-please/#findComment-802136 Share on other sites More sharing options...
phpretard Posted April 6, 2009 Author Share Posted April 6, 2009 Could you give a swift kick in the right direction with that approach? I know how the explosions work but I am a little overwhelmed with the concept at this point. Quote Link to comment https://forums.phpfreaks.com/topic/152754-solved-date-help-please/#findComment-802140 Share on other sites More sharing options...
JasonLewis Posted April 6, 2009 Share Posted April 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/152754-solved-date-help-please/#findComment-802246 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.