#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    London, England
    Posts
    64
    Rep Power
    15
    I'm just starting in PHP so this may seem obvious, please bear with me.

    I have an input form for users and I want to give the date input box the value of today's date.

    This is what I have so far for the first page:

    <?php

    $db = mysql_connect("localhost", "webuser@localhost");
    mysql_select_db("mydb",$db);

    $result = mysql_query ("SELECT curdate()");

    print "Date = ";
    print "$result";

    ?>

    This returns a value of 2.

    Then I have a page which writes this date input box:

    print ("<li> Date:</li>");
    print ("<input type='Text' name='Title' value='$result'>");
    print ("<br>");


    This returns doesn't even insert the 2 value. Perhaps I don't need 2 php pages to do this? Any ideas?

    Cheers in advance.
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    You should do both things in same page then only you get desired result.


    This returns a value of 2.


    bcoz your result has fetched some records.using mysql_fetch_array() function you will have to get that value...

    try the following

    #########-------

    test.php3

    <?php

    $db = mysql_connect("localhost", "webuser@localhost");
    mysql_select_db("mydb",$db);

    $result = mysql_query ("SELECT curdate()");

    $row=$mysql_fetch_array($result);

    echo "Date : <input type="text" value="$row[0]">n";
    ?>

    Good Luck!!!



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    London, England
    Posts
    64
    Rep Power
    15
    Just worked it out using someone else's reply. Hope this might be of use to someone else:

    <?

    $Date = date("Y m d");

    print ("<input type='Text' name='Date_Written' value='$Date'>");

    ?>

    Simple really...

Similar Threads

  1. help with tables and wordwrapping
    By junkedBrian613 in forum PHP Development
    Replies: 2
    Last Post: February 15th, 2004, 05:42 PM
  2. Replies: 7
    Last Post: February 8th, 2004, 11:16 AM
  3. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  4. carriage returns on form text box, help please
    By Favian in forum Perl Programming
    Replies: 6
    Last Post: January 18th, 2004, 06:55 PM
  5. float question
    By yeah-yeah in forum HTML Programming
    Replies: 10
    Last Post: January 15th, 2004, 03:59 PM

IMN logo majestic logo threadwatch logo seochat tools logo