aaricwon Posted February 27, 2008 Share Posted February 27, 2008 I have a form I made to submit news. It is simple... Subject, Short Story, Full Story, and I would then like the date to be posted. Can anyone tell me how to make that entered to the database automatically? Quote Link to comment Share on other sites More sharing options...
drisate Posted February 27, 2008 Share Posted February 27, 2008 you can add $date=date("m-d-Y"); or you can use the build in MySQL date Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 You can add field in your table. Let say date_posted (use TIMESTAMP) automatically after you click submit, the current time and date of the system inserted also. Quote Link to comment Share on other sites More sharing options...
bpops Posted February 27, 2008 Share Posted February 27, 2008 you can add $date=date("m-d-Y"); or you can use the build in MySQL da To add to this, use $date=date("Y-m-d"); and then you can add this string to a type 'date' column of your table. Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 ======|RowID|Subject|SStory|FStory|DatePosted========= =============================================== RowID = Primary, Auto_increment DatePosted = TYPE:timestamp I think this is the very easiest way to insert automatically the current time and date after you have posted. But there are so many ways.. Regards Quote Link to comment Share on other sites More sharing options...
timmy0320 Posted February 27, 2008 Share Posted February 27, 2008 You know, I don't know whats up but my TIMESTAMP to current_timestamp never works. My INSERT stops working so I had to do a format in PHP to get inserted into an INT. Maybe I'm just doing it wrong. Do I put anything in the INSERT or put a NULL or NOW() or don't even put a value for the TIMESTAMP. None of them work for me Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 hi, no need to put a value for a timestamp in the structure of your table. ex. namefield simply use timestamp. so in your php page no need to insert date to save because automatically the current time and date of your system save in your dbase after you have inserted some data's. but make sure try to create field for your primary key. ex rowid TYPE int, auto_increment. ========= |rowid| name | date_posted | ========== 001 John 00,00,00 00:00:00 002 Allan 00,00,00 00:00:00 ========================================== Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.