display month from mysql datetime into dropdown menu

Discussion in 'PHP' started by sakurasan, Sep 30, 2010.

  1. #1
    Hi!!

    Need help, i'm new i php...

    my problem is, i have 1 dropdown menu and i want to display only month retrieve from my database which is the field type is datetime.

    and from the drop down (which is include the month data), i want to display several data also from my database..

    plz help me...
     
    sakurasan, Sep 30, 2010 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    have you written any code for it?

    If so then share it with is so that we can suggest necessary modifications.
     
    mastermunj, Sep 30, 2010 IP
  3. axelay

    axelay Peon

    Messages:
    54
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    This will be rather clumsy to do so I would suggest you create the select box with a list of months (after all there are only 12).
    Then when you post the form, you can do something like this:
    $month = intval ($_POST['month']);
    $sql = "SELECT * FROM myTable WHERE month(theDateField) = $month";
    Code (markup):
    That should help you get started ;)

    aXe
     
    axelay, Sep 30, 2010 IP
  4. sakurasan

    sakurasan Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi mastermunj,
    i haven't written any code for that yet coz i don't know how to do it...
    i spent many days googling for it, but nothing similar with my problem...

    axe,
    can u share with me more idea about that.

    tq
     
    sakurasan, Oct 3, 2010 IP