Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can sort the data in a table by different columns?

Status
Not open for further replies.

KingDufus

Technical User
Oct 9, 2001
19
0
0
US
I have written a Perl script which reads the contents of a Microsoft Access Database, and displays certain results as a web page table. The display criteria are determined by variables that are passed along to the script by a query string in the URL. For example, dep is the department name, num is the department number and sor is sort value. The script uses if, elsif statements and the sort number to determine how the data should be sorted. For example, if the sort number = 4, then sort the data by date. The table and data displays great when you first come to the page.
I would like to have the option of clicking on each of the column titles to then sort the table by that particular column. For example, the initial sort number is 1 which sorts the data by Document Number. I would like to be able to click on another column title, such as Document Title, and have the web page refresh and display the data sorted by that column.
I tried using <a href></a> html code, and made the link the same perl script that creates the web page. In other words, it links to itself, and passes along new values for the sort number in the query string. When I try this method, the page comes up blank. I have to force reload the page (in netscape) to get the table to show up with the new sorted data. Is there a way to do this where It will just display without having to manually force reload? Or is there a beter method?
Also, another problem I am running into, is that I need to use perl variables in the query string when attempting to re-sort/reload the table. This also makes the page not display (even force reloading will not make it work when I use variables in the query string). For example, the Department Number is stored in a variable called $deptnum, and in order for the reloaded page to know what department to look for in the database, this information needs to be a part of the query string.
Thanks for your help.
-King Dufus
 
I tried using <a href></a> html code, and made the link the same perl script that creates the web page. In other words, it links to itself, and passes along new values for the sort number in the query string. When I try this method, the page comes up blank.

When you hover over the column header link, what does
the link contain - what is the value that you see for
that link in the browser?

How are you retrieving the values of the query string
parameters? Are you using CGI.pm's &quot;param&quot; method?

Does this script display a &quot;form&quot;? Are you POSTing
the form contents back into the same script?

Not really sure what the problem could be - answer these questions and maybe something will come to me. Try putting some debug &quot;print&quot;s to STDERR in your cgi script - see if you can figure out if execution is even getting back into your script when the blank screen is displayed. Prints to STDERR will show up in your webserver error log - at least they do on Linux using Apache and Perl.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Hi HTH,thanks for posting. Here are some answers to your questions:

1. The path of the Perl script is:

The value for the column header link is:
I am not currently using variables in the hyperlink. I would like to eventually, but when I do, I get a blank screen.

2. Yes, I am using the CGI.pm &quot;param&quot; function

3. I’m not sure I completely understand POSTing. (I’m new to SQL, PERL and CGI)
Users open the home page of the Intranet site. There is a list of departments. Each department is a hyperlink to the Perl script, and each hyperlink contains a query string with the specific department information in it. The Perl script then takes these values, and uses them in the SELECT FROM WHERE SORT commands to retrieve data specific to that department, and builds a table with the results in html. Is this considered POSTing?
I hope this helps! Thanks,
-King Dufus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top