in reply to Using CGI params for SQL statement

I'm having a bugger of a time trying to get the 'ORDER BY' bit to change from DESC (take as default) to ASC.

In other words, in the fragment

if ($asc_desc eq 'ASC') { $sql .= " ORDER BY $order_by ASC "; } else { $sql .= " ORDER BY $order_by DESC "; }
you're always ending up with DESC. This suggests that $asc_desc isn't 'ASC', which you should be able to verify pretty quickly be viewing source for the page you're emitting, since you're putting out $asc_desc in a hidden field.

What RDBMS are you using? If you're using MySQL, 'ASC' is the default sort order, and you only add DESC to alter the order.

Replies are listed 'Best First'.
Re: Re: Using CGI params for SQL statement
by maderman (Beadle) on Feb 26, 2002 at 08:16 UTC
    I'm using Oracle, which also has ASC as the default sort order. I forgot about that - thanks for reminding me. I gues my next task is to determine if the same column has been pressed and if so, change the SQL statement. Regards, Stacy.