in reply to Re: Spiking the mySQL parameter
in thread A Matter of Style in CGI
This is how I deal with user-defined sort orders, which I (personally) think is a little more readable. . .This is taken straight from production code. . .Plus, to add more sorts you only need to add them to the drop-down and the hash.
my %sorts=( form=>'form_list.form_title', rform=>'form_list.form_title desc', name=>'stored_forms.client_name', rname=>'stored_forms.client_name desc', prepared=>'stored_forms.advocate_name', rprepared=>'stored_forms.advocate_name desc', date=>'stored_forms.created', rdate=>'stored_forms.created desc' ); my $sort=$sorts{$q->param('sort')} || $sorts{'form'}; my $forms=$dbh->prepare("select stored_forms.client_name, form_lis +t.form_title, stored_forms.id, stored_forms.advocate_name,date_format(stored_forms.created,'%c/%e/%Y' +) as save_date, stored_forms.client_accountnum,form_list.form_location from form_list, stored_forms where form_list.form_type = stored_forms.form_type and stored_forms.client_accountnum like ? order by stored_forms.client_accountnum,".$sort);
HTH
-Any sufficiently advanced technology is
indistinguishable from doubletalk.
|
|---|