olilish Posted March 14, 2010 Report Share Posted March 14, 2010 Hello.I have the following code which simply inserts data gathered from a form and adds it to my database via post.I would like a row in the database to collect the date of when the reccord was added. I have added a DATE field to my databaseMy code:--------------------------------------------------$h1=$_POST['h1'];$body=$_POST['body'];$h2=$_POST['h2'];$a=$_POST['a'];$approved=$_POST['0'];mysql_query("INSERT INTO pages (h1, body, h2, a, approved) VALUES ('$h1', '$body', '$h2', '$a', '$approved')");-------------------------------------------------I believe I can use the CURDATE to automatically add the current date. I have expeirmented with this but can only seem to add a date manually.Any help would be great! - thanks! Link to comment Share on other sites More sharing options...
phpnoob Posted March 15, 2010 Report Share Posted March 15, 2010 Hello.I have the following code which simply inserts data gathered from a form and adds it to my database via post.I would like a row in the database to collect the date of when the reccord was added. I have added a DATE field to my databaseMy code:--------------------------------------------------$h1=$_POST['h1'];$body=$_POST['body'];$h2=$_POST['h2'];$a=$_POST['a'];$approved=$_POST['0'];mysql_query("INSERT INTO pages (h1, body, h2, a, approved) VALUES ('$h1', '$body', '$h2', '$a', '$approved')");-------------------------------------------------I believe I can use the CURDATE to automatically add the current date. I have expeirmented with this but can only seem to add a date manually.Any help would be great! - thanks!i always useing a mysql support, i mean i'm choice timestamp type with an Attributes:'ON UPDATE CURRENT_TIMESTAMP' and Default:"CURRENT_TIMESTAMP"If this not good for you than try this one $date=date("Y-m-d H:i:s"); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now