Web form dates to MySQL

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Web form dates to MySQL

    I am building a admin form (PHP/MySQL), so staff can input Job Vacancy
    descriptions into the Website via a Web form that can be displayed on the Web.
    I need it to be able for user's to include a Closing date for the application
    submission. Obviously I can't use a time-stamp for this function because the
    closing dates are always in the future. As MySQL date format is baffling at
    the best of times, I cant get the staff to remember MySQL date format. So I
    want to create 3 drop down box's with DAY, MONTH & YEAR, but how do I get
    3 form elements into 1 MySQL field? I've been looking around the Net for hours
    for a solution, but havent come up trumps yet unfortunately. Is there an easy
    way of doing this in dreamweaver? or is thing done with Javascript or PHP...
    can anyone point me in the right direction plz - thanks If there are any other
    solutions other than 3 drop down boxes - plz let me know too :-)

    Andy Burton Guest

  2. Similar Questions and Discussions

    1. How to you compare dates in a query in Mysql
      Dear friends, Plesae help in finding the correct syntax for comparing two dates in a query in MySql database Thank you Subodh Gupta
    2. MySQL Dates
      Hello, I have CFM pages with Searching on Dates in MySQL. As you know MySQL Dates are "yyyy-mm-dd" format. However, we want date entering formats...
    3. Searching on Dates in MySQL
      Hello, I have CFM pages with Searching on Dates in MySQL. As you know MySQL Dates are "yyyy-mm-dd" format. However, we want date entering formats...
    4. Array of Dates from MYSQL?...
      This has been puzzelling me for a couple of weeks now, and just can't figure it out. Does anyone know how to return an array of dates from MySQL...
    5. Selecting a range of dates in MySql
      I need to do a search in MySql for birth date range. (i.e. for birth date Any suggestions on how to do this select? Thanks!
  3. #2

    Default Re: Web form dates to MySQL

    If you have three drop down boxes, called day, month, year, just combine
    them into one string, and then insert the string into your field in the
    database eg

    $mysqlDate = $_POST['year'] . "-" . $_POST['month'] . "-" . $_POST['day'];

    Then insert $mysqlDate into your database date field


    --
    Gareth - TMM Dreamweaver
    [url]http://www.dreamweavermxsupport.com/[/url]
    [url]http://www.garethdp.com/[/url]

    PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.
    [url]http://www.phploginsuite.co.uk/[/url]

    Co-Author: Dreamweaver MX: Instant Troubleshooter - Apress
    Co-Author: Practical Intranet Development - Apress
    Co-Author: Dreamweaver MX: Advanced PHP Web Development - Apress
    Co-Author: Dreamweaver MX: PHP Web Development - Wrox


    gareth Guest

  4. #3

    Default Re: Web form dates to MySQL

    If you're using php then the three values can be combined. If you call the
    select menus day, month and year then after submitting the form you can access
    the values as- $_POST['day'], $_POST['month'], $_POST['year'] to combine them
    just use.... $date=$_POST['day'].$_POST['month'].$_POST['year']; or more likely
    $date=$_POST['year'].$_POST['month'].$_POST['day']; which is the normal order
    for a timestamp. There are other ways you can do this. You could ask them to
    enter in normal date format(dd/mm/yyyy), but obviously you will need to do some
    validation to make sure it's been entered properly. The select menus is
    probably the most foolproof method though. If you need any more specific help
    then repost.

    Ross Riley Guest

  5. #4

    Default Re: Web form dates to MySQL

    Thanks for your help guys, I have nearly got it to work although there is a
    slight problem. The Closing Date field was stil returning 0000.00.00 so I set
    up a Test field in MySQL and set it to TEXT, just to see what was being passed
    through. After using this php statement $Mysql_ClosingDate =
    $_POST['selectYear']. '-'. $_POST['selectMonth']. '-'. $_POST['selectDay'];
    and putting in my Form fields: 2005 12 30 (year,month,day) instead of
    printing 2005-12-30 to the MySQL field... it was returning a value of 1963...
    which I realised 2005 minus 12 minus 30 = 1963 ahhhhhh. What is the correct
    statement to use Thanks

    Andy Burton Guest

  6. #5

    Default Re: Web form dates to MySQL

    On Fri, 25 Mar 2005 13:00:03 +0000 (UTC), Andy Burton
    <webforumsuser@macromedia.com> wrote:
    > Thanks for your help guys, I have nearly got it to work although there
    > is a
    > slight problem. The Closing Date field was stil returning 0000.00.00 so
    > I set
    > up a Test field in MySQL and set it to TEXT, just to see what was being
    > passed
    > through. After using this php statement $Mysql_ClosingDate =
    > $_POST['selectYear']. '-'. $_POST['selectMonth']. '-'.
    > $_POST['selectDay'];
    > and putting in my Form fields: 2005 12 30 (year,month,day) instead of
    > printing 2005-12-30 to the MySQL field... it was returning a value of
    > 1963...
    > which I realised 2005 minus 12 minus 30 = 1963 ahhhhhh. What is the
    > correct
    > statement to use Thanks
    >
    Hi, date is the best way to go for it, you might also want to know the
    different date functions mysql has. This way you would be able to work it
    out better:
    You got NOW() Timestamp() CURRENT_TIME() and others:
    [url]http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html[/url]

    --
    Alexandro Colorado
    ------------------------------
    Support Engineer
    InterAKT Online
    [url]http://www.interaktonline.com[/url]
    Tel: 40(21) 312.5312
    Alexandro Colorado Guest

  7. #6

    Default Re: Web form dates to MySQL

    Thanks guys... I finally got it to work. I put it in TIMESTAMP order like Ross
    &amp; Alex suggested $Mysql_ClosingDate=$_POST['selectYear'].
    $_POST['selectMonth']. $_POST['selectDay']; All 3 form fields pass through to
    a single MySQL DATE field OK now. Thanks for pointing me in the right
    direction.

    Andy Burton Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139