Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date field in MySQL interface

Status
Not open for further replies.

george123456724

Technical User
Feb 26, 2002
6
GB
Hi,

I must stress I don't know *anything* about PHP coding!

I am using a PHP MySQL interface. The date field for new entries is split into selection lists for day (00 to 31), month (00 to 12) and year (currently 2002 to 2005). I want to change the code to allow me to choose between 2002, 2003, 2004, 2005 and also 0000 - giving the option of an unspecified year in my database.

The code in the php script for generating the year selection box is shown below. The values for start_year and end_year are obtained from a config.php file, which I can easily edit.

Can anyone tell me how I can change the script to get non-sequential values into this selection box as explained above?

_________________

Code:
for ($i=$start_year; $i<=$end_year; $i++){
        $year_select .= &quot;<option value=\&quot;$i\&quot;&quot;;
        if($year != &quot;&quot; and $year == $i){
            $year_select .= &quot; selected&quot;;
        } // end if
        $year_select .= &quot;>$i</option>&quot;;
    } // end for
__________________

Many thanks

George
 
try this :

$year_select .= &quot;<option value=0000>0000</option>&quot;;
$year_select .= &quot;<option value=0001>0001</option>&quot;;
// well ... you get the idea now.

for ($i=$start_year; $i<=$end_year; $i++){
$year_select .= &quot;<option value=\&quot;$i\&quot;&quot;;
if($year != &quot;&quot; and $year == $i){
$year_select .= &quot; selected&quot;;
} // end if
$year_select .= &quot;>$i</option>&quot;;
} // end for

cheers
devnull22
(Knowledge Base Center )


--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top