If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > autoenter date and klickable web-urls.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-17-04, 18:52
giobbi giobbi is offline
Registered User
 
Join Date: Jan 2004
Posts: 3
Talking 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..
Reply With Quote
  #2 (permalink)  
Old 01-21-04, 01:34
zkenet zkenet is offline
Registered User
 
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 04:19.
Reply With Quote
  #3 (permalink)  
Old 01-21-04, 06:49
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 01-21-04, 08:30
giobbi giobbi is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 01-22-04, 16:05
giobbi giobbi is offline
Registered User
 
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..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On