maderman has asked for the wisdom of the Perl Monks concerning the following question:
Don't worry about column name generation for now... Now the default SQL is 'SELECT * FROM TABLE' and when I press the 'FAULT_NO' button, the SQL statement becomes 'SELECT * FROM TABLE ORDER BY FAULT_NO DESC'. Similar results for the other buttons. Looks like I have the table column changing as it should, but I'm having a bugger of a time trying to get the 'ORDER BY' bit to change from DESC (take as default) to ASC... A little help please? Many thanks, Stacy.use strict; my ($order_by,$sql,$asc_desc); $sql = qq{SELECT * FROM TABLE}; $order_by = param('order_by'); $asc_desc = param('asc_desc'); if (defined($order_by)) { if ($asc_desc eq 'ASC') { $sql .= " ORDER BY $order_by ASC "; } else { $sql .= " ORDER BY $order_by DESC "; } } print header, start_html(), start_form(), center( p($order_by), start_table(), Tr(td(submit('order_by','FAULT_NO',)), td(submit('order_by','ISSUE')), td(submit('order_by','RESPONSE'))), end_table(), hidden('order_by',$order_by), hidden('asc_desc',$asc_desc), p($sql), ), end_form(), end_html(); exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using CGI params for SQL statement
by dws (Chancellor) on Feb 26, 2002 at 07:44 UTC | |
by maderman (Beadle) on Feb 26, 2002 at 08:16 UTC | |
|
Re: Using CGI params for SQL statement
by IlyaM (Parson) on Feb 26, 2002 at 09:31 UTC | |
by maderman (Beadle) on Feb 26, 2002 at 09:42 UTC | |
by IlyaM (Parson) on Feb 26, 2002 at 12:50 UTC | |
by maderman (Beadle) on Feb 26, 2002 at 14:12 UTC | |
|
Re: Using CGI params for SQL statement
by George_Sherston (Vicar) on Feb 26, 2002 at 10:16 UTC | |
by maderman (Beadle) on Feb 26, 2002 at 10:49 UTC | |
by jeffa (Bishop) on Feb 26, 2002 at 18:14 UTC |