change data before its sent to db?

From: Date: Tue, 16 Jul 2002 21:19:57 +0000
Subject: change data before its sent to db?
Groups: php.db 
Request: Send a blank email to php-db+get-20580@lists.php.net to get a copy of this message
I have a form with a select box of the 12 months + one for none. It (and more) are sent to a mysql database. On another web page a list is displayed and can be sorted by date, but of course the month names are not alphabetical. I tried to assign each month a number, 01,02,03, etc in a if-elseif statement, then send it to the database but that wouldn't work. if ($month == 'jan') { $month = '01';} elseif ($month == 'feb') {$month = '02'}; etc, so I can then sort numerically, and it will display in the correct order on the web page. I have tried various versions of the above but it will not work. I know I could use numbers instead of names for the months - but for this application that would not be appropriate. The sort code --- if ($orderby == 'month_num'): $sql = "select * from releases order by 'month'"; elseif ($orderby == 'month_num2'): $sql = "select * from releases order by 'month' desc"; The html select ---- <td valign="bottom">Month:<br /> <select name="month"> <option value="000">None <option value="Jan">Jan <option value="Feb">Feb etc </select> -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com chip.wiegand@simrad.com "There is no reason anyone would want a computer in their home." --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!)

« previous php.db (#20580) next »