...

View Full Version : Date Column



grandgefx
01-13-2012, 10:04 AM
Hello,
So I want to create a Mysql table on my phpMyadmin with : id, id_member, date, and message
so can anyone help me to set up the attribute for each column/field?

Field: ID
Type: INT
Length/Values: 11
Default: None
Collation:
Attributes:
Null: <---- this is a check box
AUTO_INCREMENT <----check box
Comment:

Field: id_member <--- which is registered user of the website
Type: ?
Length/Values: ?
Default: None
Collation:
Attributes:
Null: <---- this is a check box
AUTO_INCREMENT <--
Comment:

Field: date <--- which is the current time and date
Type: ?
Length/Values: ?
Default: None
Collation:
Attributes:
Null: <---- this is a check box
AUTO_INCREMENT <---- another check box
Comment:


Field: message
Type: ?
Length/Values: ?
Default: None
Collation:
Attributes:
Null: <---- this is a check box
AUTO_INCREMENT <---- another check box
Comment:

helenp
01-13-2012, 02:43 PM
I recomend you to do some homework,
there are lot of information in google,
this is the first I found:
http://help.scibit.com/mascon/masconMySQL_Field_Types.html

Old Pedant
01-13-2012, 08:32 PM
Forget using phpmyadmin to do a field at a time.

Just do it with a SQL query:


CREATE TABLE nameOfTable (
id INT AUTO_INCREMENT PRIMARY KEY,
id_member INT REFERENCES members(id),
theDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
message TEXT );


You said

Field: id_member <--- which is registered user of the website so I assumed you meant you have another table (which I assumed is named members) with a column for the id of the member. If the other table and/or field name is not members(id) then change that to match what you are actually using.

The only way you can have a default value of "current time and date" in MYSQL is the way I showed it there. I urge you *NOT* to name the column just date as that name is a builtin function name in MySQL and can lead to confusion. Just use a simple variation on the name, such as theDate as I showed there.

Finally, you didn't say how long a message can be, so I used text as the data type, which allows message of virtually any length. If messages can't be more than a few thousand characters, it might (or might not) be worth using a different type.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum