mysql table field choices
| From: | Andy B | Date: | Sun, 28 Mar 2004 03:16:54 +0000 |
| Subject: | mysql table field choices | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181622@lists.php.net to get a copy of this message | ||
just a short one here... what would be the best type of field for a combo box that looks like this:
<select name="month" accesskey="m">
<option value="">---pick a month---</option>
<option value="1">January</option>
<option value="2">February</option>
....
</select>
and the same thing with the year...
was thinking either int(2) for the month and int(4) for the year but would enum(1, 2, 3, 4...12) be
better for the month and enum(2004, 2005, 2007....) be better for the year?? dont know what one of
those would be better/faster...
and was thinking of timestamp(14) for the result of this function:
/* StartTime: create a timestamp
parameters:
$day: text representation of the day of the month.
examples: "next week", "third monday", "fourth saturday", and so on
$month: valid month number of the year. valid values are 1-12 (without the leading 0).
$year: any valid 4 digit year between 1970 and 2038
discription:
StartTime(string day, int month, int year);
return values: if successful returns a valid timestamp in the form of the total number of seconds
between jan 1, 1970 and the time created. otherwise returns false if failed.*/
function StartTime($day, $month, $year) {
if(!empty($day) && !empty($month) && !empty($year)){
//convert $day, $month, and $year into a valid timestamp
$time= strtotime($day, mktime(0,0,0,$month,1,$year));
return $time; }
else {
return false; }}