daniish Posted October 8, 2006 Share Posted October 8, 2006 Hello,I have the following date selector in an html form:[code]<form name=add_blog action="insert.php" method="post">Title: <br><input type="text" size="79" id="title" method="post" name="title"></input> <br><br>Date: <br><select id="daydropdown"></select> <select id="monthdropdown"></select> <select id="yeardropdown"></select> <br><br>[/code]How do i concatenate the DATE values and save them in a variable that i can assign to a field in my SQL database?Many thanks for your help Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 8, 2006 Share Posted October 8, 2006 Use this as the html for your drop down menus[code]<select id="dropdown['day']"></select> <select id="dropdown['month']"></select> <select id="dropdown['year']"></select>[/code]Then you can access the day, month and year in a single variable called ($_POSt['dropdown'], which will hold an array of the three drop downs.To access the day you can use $_POST['dropdown']['day'], for the the month you use $_POST['dropdown']['month'] and $_POST['dropdown'][year'] to get the year.When you want to add them into the database, you can use implode function. Eg:[code=php:0]$date = implode("-", $_POST['dropdown'];[/code]What this will do is produce something like this: day-month-yearDoes that help? Quote Link to comment Share on other sites More sharing options...
daniish Posted October 8, 2006 Author Share Posted October 8, 2006 Hmm i like arrays:)do you think i can get your method to work with the javascript i am using:[url=http://www.javascriptkit.com/script/script2/curdateform2.shtml]http://www.javascriptkit.com/script/script2/curdateform2.shtml[/url]Cheers! Quote Link to comment Share on other sites More sharing options...
daniish Posted October 8, 2006 Author Share Posted October 8, 2006 SOLVED!Many thanks for your help ;D Quote Link to comment Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 Of course, you could just use a proper date picker and be done with it. Quote Link to comment Share on other sites More sharing options...
anatak Posted October 19, 2006 Share Posted October 19, 2006 Hey fenway,what do you mean with a date picker ?do you have a url with some more explanation ?kind regardsanatak Quote Link to comment Share on other sites More sharing options...
fenway Posted October 19, 2006 Share Posted October 19, 2006 A custom control that a) makes sure you pick a valid date and b) places the full SQL-99 date string into a form field. Quote Link to comment Share on other sites More sharing options...
anatak Posted October 19, 2006 Share Posted October 19, 2006 ah ok.I see. I thought you knew some mysterious function that did all the above for you.custom = self written thxanatak Quote Link to comment Share on other sites More sharing options...
fenway Posted October 19, 2006 Share Posted October 19, 2006 That's generally the only way to get anything done properly ;-) Quote Link to comment Share on other sites More sharing options...
anatak Posted October 23, 2006 Share Posted October 23, 2006 trueand since I have a real dislike for programming anything time related I was more than interested to get my pawns on a killer function that does it for me ;) 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.