CGI::Browse

HTML table from MySQL to display rows with sortable columns, flexible delete links, and multiple column link-outs
Download

CGI::Browse Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Roger A Hall
  • Publisher web site:
  • http://search.cpan.org/~rogerhall/

CGI::Browse Tags


CGI::Browse Description

HTML table from MySQL to display rows with sortable columns, flexible delete links, and multiple column link-outs CGI::Browse is a Perl module that enables a browsable list for data with controls to set the viewing window (page length), page to previous and next pages, jump to a page, resort the rows by column headers, delete rows, and define link-outs for multiple columns. Links to working examples are listed below, and the CGI scripts are included.The Browse object can be used with the default HTML layout, which includes all of the labeling features, such as "Sorted by" and "Starting row". use CGI::Browse; # Get CGI variables using favorite method # Define table fields my $fields = ; # Define browse parameters (including fields and matching SQL statement) my $params = { fields = > $fields, sql = > "select state_capital_id, state, statehood_year, capital, capital_since, most_populous, city_population, metro_population, notes from state_capitals", connect = > { db => 'mydb', host = > 'localhost', user = > 'user', pass = > 'pass' }, urls = > { root => 'http://www.ourpug.org/', browse = > 'cgi-bin/eg/browse.cgi', link1 = > 'cgi-bin/eg/browse_link1.cgi?id=', link2 = > 'cgi-bin/eg/browse_link2.cgi?id=', delete = > 'cgi-bin/eg/browse_delete.cgi?id=' }, classes = > , features = > { default_html = > 1, delete = > 'each' } }; # Create the browse object my $browse = CGI::Browse- >new( $params ); # Build HTML page my $html = "Content-type: text/html\n"; $html .= "Status: 200 OK \n\n"; $html .= "< html >\n"; $html .= "< head >\n"; $html .= " < title >CGI::Browse Module Sample Script< /title >\n"; $html .= $browse- >_build_styles(); # Defines included styles $html .= "< /head >\n"; $html .= "< body >\n"; $html .= $browse- >build( \%cgi_vars ); $html .= "< /body >\n"; $html .= "< /html >\n"; # Print page print $html;A working example of this form is available at http://www.ourpug.org/cgi-bin/eg/browse.cgi and is included in this package as "scripts/browse.cgi".It can also be used with a Template system (such as Template Toolkit) by removing the "default_html" feature. Using this method, you can decide which of the features you wish to use on your form. use Template; use CGI::Browse; ... my $params = { fields = > $fields, sql = > "select state_capital_id, state, statehood_year, capital, capital_since, most_populous, city_population, metro_population, notes from state_capitals", connect = > { db = > 'mydb', host = > 'localhost', user = > 'user', pass = > 'pass' }, urls = > { root = > 'http://www.ourpug.org/', browse = > 'cgi-bin/eg/browse_tmpl.cgi', link1 = > 'cgi-bin/eg/browse_link1.cgi?id=', link2 = > 'cgi-bin/eg/browse_link2.cgi?id=', delete = > 'cgi-bin/eg/browse_delete.cgi' }, classes = > , features = > { delete = > 'multi' } }; my $browse = CGI::Browse- >new( $params ); my $build = $browse- >build( \%cgi_vars ); my $template = Template- >new(); $template- >process( \$tmpl, $build );A working example of this form is available at http://www.ourpug.org/cgi-bin/eg/browse_tmpl.cgi and is included in this package as "scripts/browse_tmpl.cgi". Requirements: · Perl


CGI::Browse Related Software