Hi all. I am just learning this stuff and have created a simple site and can pull information from the database and onto the page. I can also create forms and add to the data base. I'm stuck on how to get the sign up date to apear on the database for me to pull the info from. Can someone direct me to a good tutorial or can give me the code. I tried to read up on it through google search but can't find the code. I think it is called a time stamp. Is this correct?
Hey Scott, MySQL actually has a field, I believe is called Timestamp. On there, is an option which is something like 'current timestamp' (it's a checkbox IIRC). It will automatically insert the current time when you add an entry. I've never liked this option, though. I find it a little difficult to work with when querying the database. Another method (and one which I use), is to simply insert time() as the field value when adding the row to the database
Thanks for the reply. I have been trying everything to get this to work but nothing. I have member_since in a field value for new row upon sign up. I have datetime in type and have set the function to currentdate. It shows the callender and date under value but it just stays at 0000. How did you get yours set up to work?
You can do it with two different ways: 1) Set your member_since field to be of type "TIMESTAMP" and set it's default value to "CURRENT_TIMESTAMP". Whenever a new entry is created, your field member_since will have the current timestamp inserted into it. Make sure though, you don't include this field in your INSERT query with any value, as it won't be updated with the default value which is the CURRENT_TIMESTAMP, but with the value you have in your INSERT query instead. If you need to update already existing fields, you need to do something like "UPDATE table SET member_since = NOW()". Keep in mind though, that this isn't going to work with another field that you would have set the attribute to UPDATE TIMESTAMP when a row gets modified. 2) A approach more preferred by many is, to set the type of member_since to DATETIME and whenever you insert a new account, set the value of the field by using the function NOW(). When having two example fields like member_name and member_password, this could look something like "INSERT INTO table (member_name, member_password, member_since) VALUES ('membername', 'password', NOW())". Both methods actually work and more often it's a personal preference which one you select.