|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||||||||
|
|||||||||||
|
Problem reading Month from MySQL to PHP
What the heck am I doing wrong???
Simple situation, I use drop downs to populate dates on a form. I have a drop down for month, day and year. I store everything in the MySQL DB as yyyy-mm-dd, but on the web page I use Month day Year format. Now the user enters the date (simple enough) but then when they come back they can modify the date if they need to. To allow them to do this I first select their date information from the database... START CODE SNIP: php Code:
END CODE SNIP: Now with this information I populate the various drop down boxes. The year works fine so here is an example. START CODE SNIP: php Code:
END CODE SNIP: That works just fine, and so does the day of the month. Same idea as above. Trouble is with the month. Since I am storing the month in the 2 digit format in the database I have a little function to handle the DB to Human translation, or so I thought. Here is the funtion START CODE SNIP: php Code:
END CODE SNIP: OK so when I call the variable that I have pulled from the DB as the month (for example 02 for February) I get nothing from the array. No error just a blank drop down. BUT if the variable is greater then 10 (or later in the year then October) IT WORKS!! Please see below... START CODE SNIP: END CODE SNIP: Does any one see what I might be doing wrong? Or perhaps knows an alternative? |
|
#2
|
|||
|
|||
|
RE: Problem reading Month from MySQL to PHP
The value coming from the database doesn't have the leading zero...so, it can't find a key in the array that is just 1 as the key is 01. Modify your function to not have leading zeros...
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Problem reading Month from MySQL to PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|