Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    3

    Talking Unanswered: autoenter date and klickable web-urls.

    Hi all. Im just getting the hang of simple Mysql-stuff but i cant figure out how to autoenter date in my date-field. I made it NOT NULL and default 0000-00-00 but i only get the zeros in all the posts, datefiled.
    I also have a filed that people puts weburls in but when i se them in a webbrowser i they are not klickable, how do i do that.

    Many thanks..

  2. #2
    Join Date
    Jan 2004
    Location
    Toronto
    Posts
    33
    1) Re date field
    As far as I know you cannot default the field to NOW. What you can do when the record is created add the current time in the SQL statement:
    "INSERT INTO.... (... ,col_date,...) VALUES (..., NOW(),...)
    (instead of NOW you can put a specific date/time)

    2) Re URL
    When you output the url value, add HTML tag for link (ASP example):
    response.write "<a href=""" & theURL & """>" & theURL & "</a>"
    Last edited by zkenet; 01-21-04 at 05:19.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yet another torontonian

    1) is correct, you cannot default a field to any function, but you could also use a TIMESTAMP --

    "The TIMESTAMP column type provides a type that you can use to automatically mark INSERT or UPDATE operations with the current date and time"
    -- http://www.mysql.com/doc/en/DATETIME.html
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Jan 2004
    Posts
    3
    Thanks for the reply!! I will try it out tonight. So, when i do a POST in my form i put NOW() where my date-field is?

    Is it the same syntax in MySQL as in ASP? I saw that ur web-url-klickable trick was an ASP-syntax?

    Thx again.

  5. #5
    Join Date
    Jan 2004
    Posts
    3
    Hi again. I did manage the auto input on date but the web-url-thing i can't figure out, i would love to have some help here, see my .php file:

    <?php
    $conn = mysql_connect("localhost", "root", "xxx");

    mysql_select_db("receptionen",$conn);

    $sql = "select * from emosms";

    $result = mysql_query($sql, $conn) or die(mysql_error());

    while ($newArray = mysql_fetch_array($result)) {

    $namn = $newArray['namn'];

    $mobil = $newArray['mobil'];

    echo "$namn $mobil<br>";

    }

    ?>

    How dow i do it? Thx..

Posting Permissions

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