use CGI qw(:standard :netscape *table); use CGI::Carp qw(fatalsToBrowser); use CGI::Pretty qw( :html3 ); use strict; my ($order_by,$sql,$order_by_check,$order_by_input); $sql = qq{SELECT * FROM TABLE}; $order_by = param('order_by'); $order_by_check = param('order_by_check'); if ($order_by) { $sql .= " ORDER BY $order_by "; if ($order_by_check eq $order_by) { $sql .= ' DESC '; $order_by_check = $order_by; } else { $sql .= ' ASC '; $order_by_input = ""; } } print header, start_html(), start_form(), center( start_table(), Tr(td(submit('order_by','FAULT_NO',)), td(submit('order_by','ISSUE')), td(submit('order_by','RESPONSE'))), end_table(), p($sql), $order_by_input, ), end_form(), end_html(); exit;