[Tutor] Python - html tables - cgi question

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 4 Dec 2001 14:12:09 -0800 (PST)

On Tue, 4 Dec 2001, Ross Yahnke wrote:

> Hi All - Strictly speaking this is more of a html/cgi question but I
> really want to use Python to do it!
> I have a text file with tab delimited data in it. I want to present it as an
> html table that's in sorted order. Each column heading I'd like to be a
> clickable link so that when I click on it, the table regenerates resorted
> under the column clicked on.
> I can get Python cgi to display a static list with no links only sorted by a
> pre-chosen column. How do I go do the next step to let the viewer decide how
> the table is to be sorted?

Hmmm... You might be able to do this by allowing the column titles itself
to be clickable, and adding an optional "sort_by" parameter to your CGI
program.  This way, you can allow users the option to choose the sorting
order in a way that's somewhat consistant with a spreadsheet user

Grabbing parameters from a CGI involves using the 'cgi' module:


If you have questions, please feel free to ask them on Tutor.  We'll be
happy to help you get your program going!  Good luck!