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 Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/ 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? Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-105984 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! Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-105988 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 Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-105990 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. Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-106903 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 Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-111070 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. Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-111391 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 Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-111566 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 ;-) Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-111579 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 ;) Link to comment https://forums.phpfreaks.com/topic/23374-howto-concatenate-values-and-save-in-a-single-variable/#findComment-112995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.