Good afternoon, 
This is my first shot at using CGI.pm (using the function-oriented style).
I can't seem to get my script to read values from my web page.
http://dowda.rockin.net/cgi/sql_sort2.pl

Here is part of the script. Your comments are welcome.
Special thanks to [EMAIL PROTECTED] (Curtis Poe) for jump start on this.

One last question, is there a better or different way to pad the buttons of
a radio group with spaces then to add them to hash values?
Thanks 
Dave


--------------------
#!/usr/bin/perl -w

use CGI qw/:standard/;

require "dbi-lib.pl";

# use strict;

# use CGI qw/:standard :html :cgi-lib/;


my ($sex,$sort_by,$sort_direction,$new_row ,$row_count, $first_name, $last_name, 
$birthday, $gender, $height, $weight);

$new_row ="<tr>\n";

&initialize_dbi;
&run_statement("select * from friends;");

## Get sort order via post method
#my %FORM_DATA = Vars;

# $sort_by = $FORM_DATA{sort_order} || 0;
# $sort_by = 0;

####

my %sort_by =(
    0 => 'Nothing ',
    1 => 'Hash ',
    2 => 'First Name ',
    3 => 'Last Name ',
    4 => 'Birthday ',
    5 => 'Sex ',
    6 => 'Height ',
    7 => 'Weight ',
);


# Was hash this really necessary,  
my %sort_direction =(
    0 => 'High to Low ',
    1 => 'Low to High  ',
);




print header,
      start_html( -title => 'SQL Sort with CGI.pm' ),
      start_form( -method => 'POST' ),
   
       radio_group(
        -name    => 'sort_by',
        -values  => [ keys %sort_by ],
        -default => $sort_by,
        -labels  => \%sort_by
      );
      
     print "<p>", submit( -value => 'Sort Data' ), " &nbsp;&nbsp; ",
     
        radio_group(
        -name    => 'sort_direction',
        -values  => [ keys %sort_direction ],
        -default => $sort_direction,
        -labels  => \%sort_direction
      ),
     
     "</p>\n";
print end_form;
$sort_by = param('sort_by') || 0; # Sort by Name, sex, ect...
$sort_direction = param('sort_direction') || 0; # Sort Direction for numbers

print "-"x100,"\n";

foreach $names (param()){
print "<b>Data in: $names = param($names)</b><br>\n"
} 


# strip off white space
my $tmp;
($tmp = $sort_by{$sort_by}) =~ s/\s+//g;  

print p( 'Sort Database by' . font( { color => 'red' }, " $tmp:  \$sort_by= $sort_by 
") .  param('sort_direction') .'test');
 
   

*====================================================*
*   Cora Connection Your West African Music Source   *  
*   http://www.coraconnection.com/                   *  
*   Resources, Recordings, Instruments & More!       *
*====================================================*

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to