1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem with selecting a date from the db

Discussion in 'PHP' started by tyler_durden, Apr 2, 2007.

  1. #1
    I'm getting the hang of php a bit now, but the whole date thing still blows my mind. I have this code below that allows you to select a month, from a drop down box, and the selected option is always the current month. I want this selected month to be one already in the db from a time stamp. Here is the current code below, and below that the code I tried changing to, which of course does not work..


    //-- Date --
    // $monthname=date(\"F\");
    $monthnum=date('m');
    $yearnum=date('Y');
    $dayname=date('j');
    $daynum=date('d');
    
    
    // mese
    $mese=
      "<SELECT NAME=month>"
    . "<OPTION SELECTED VALUE=" . $monthnum . ">" . $ndx_mese[((integer)$monthnum)] . "</OPTION>"
    . "<OPTION VALUE=01>" . $ndx_mese[1] . "</OPTION>"
    . "<OPTION VALUE=02>" . $ndx_mese[2] . "</OPTION>"
    Code (markup):

    <?
    $remid = $_GET['remid'];
    
    function db2me( $date )
    {    
    return date( "m d, Y", strtotime( $time ) );
    }
    if( !($result = mysql_query("SELECT * FROM reminders WHERE remid='$remid'")) ): die("Cannot query mysql server");
    elseif( !mysql_num_rows( $result ) ): 
    printf("No records found for %s", $my->username );
    else: 
    
    $date_field=mysql_result($result,$i,"date_field");
    
    //-- Date --
    // $monthname=date(\"F\");
    $monthnum=date('m');
    $yearnum=date('Y');
    $dayname=date('j');
    $daynum=date('d');
    
    
    // mese
    $mese=
      "<SELECT NAME=month>"
    . "<OPTION SELECTED VALUE=" . $monthnum . ">" . $ndx_mese[((integer)$monthnum)] . "</OPTION>"
    . "<OPTION VALUE=01>" . $ndx_mese[1] . "</OPTION>"
    . "<OPTION VALUE=02>" . $ndx_mese[2] . "</OPTION>"
    Code (markup):
     
    tyler_durden, Apr 2, 2007 IP