#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    Hiya all!

    I have a form that imputs data to database (1 table) and it gives an automatic id (auto_increment). When the from is posted I want to show a message showing the id number. I keep getting 0 but when I check the table the rows are added but it won't give out the id (keep getting 0). Any help?

    Furthermore, is it possible when you create a tbale with a `date' row that you set the date for the current date? So that when the form is posted it adds the currentdate to that row?

    Thanks in advance,

    Fillem

    PS: I use MySQL in conjunction with PHP
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    OK, i just figured out the second part of the question...
    In case you're interested:
    In the form:
    <?php
    $mutdate = date("Ymd");
    print ("<INPUT type="hidden" name="mutation_date" value="$mutdate"></td></tr>");
    ?>

    In the PHP (when submit is clicked):
    $sql = "insert into cudaba (mutation_date)
    values ("$mutation_date")";

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    And I solved the first riddle as well...

    mysql_query( $query, $connection );
    $vn = mysql_insert_id();

    echo "<h1>Thank you. Volgnummer is: $vn. </h1>";

    Thanks anyway!! )
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    INSERT INTO your_table (date_column) VALUES (NOW());

    That will work for the current time also. That way you don't need the extra hidden field and date() call.

    ---John Holmes...
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    I'm probably doing something wrong (or I just don't understand the explanation )

    but do i actually put in the values for date:

    NOW()

    becuase this doesn't seem to work for me...

    Fillem
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    OK, the id thing also doesn't work. Somehow it now adds the record twice (!) when I submit. I know the problem is somewhere here:

    mysql_query( $query, $connection );
    $vn = mysql_insert_id();

    where $query is the query I just executed...
    Don't know how to rewrite that...

    pfff...

    Fillem

Similar Threads

  1. How to save form data to be recalled at a later date
    By Brutality in forum ColdFusion Development
    Replies: 3
    Last Post: February 8th, 2004, 02:31 PM
  2. A DateDiff() Question...
    By Schway442 in forum ASP Programming
    Replies: 2
    Last Post: February 6th, 2004, 11:43 AM
  3. Get birthday date
    By alcibar in forum PHP Development
    Replies: 2
    Last Post: January 26th, 2004, 06:50 PM
  4. Displaying the latest db change date
    By d-woo in forum MySQL Help
    Replies: 6
    Last Post: January 9th, 2004, 02:40 PM
  5. Replies: 15
    Last Post: January 8th, 2004, 05:54 PM

IMN logo majestic logo threadwatch logo seochat tools logo