I have a MySQL database that uses the datetime date type for the date_time column.
I use the DATE_FORMAT() to retrieve the different parts of the date and time:
$sql = "SELECT subject, html, id, DATE_FORMAT(date_time,'%c') AS month, DATE_FORMAT(date_time,'%e') AS day, ";
$sql .= "DATE_FORMAT(date_time,'%Y') AS year, DATE_FORMAT(date_time,'%l') AS hour, DATE_FORMAT(date_time,'%i') AS minute, ";
$sql .= "DATE_FORMAT(date_time,'%p') AS ampm ";
$sql .= "FROM `tbl_calendar` WHERE `id` = '".$_GET['id']."' LIMIT 1";
In my edit form...I have the fields like this:
Subject - Textbox
HTML - Textbox
Year - Dropdown
Month - Dropdown
Day - Dropdown
Hour - Dropdown
Minute - Dropdown
Ampm - Dropdown
I was wondering how I set the default value of the dropdown menus to display what the query returns.
Eg: If the date_time field returns 2005-08-09 11:00:00, then the default value for year would be 2005, month 8, day 09, etc.
How would I do that?
Thanks for all your help in advance.