CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [allan1962] Creating alphabetic Sort: Edit Log



allan1962
Novice

Jun 4, 2007, 4:30 PM


Views: 5048
Re: [allan1962] Creating alphabetic Sort

OK, I've got it, took a little bit of playing around but here is what I have.

http://www.peibd.com/cgi-bin/testdata/data3.cgi

#!/usr/bin/perl

################################################################
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# strip off any possible SSI comment tags.
$value =~ s/<!--(.|\n)*-->//g;
$in{$name} = $value;
}
print "Content-type: text/html\n\n";

print <<TOPOFPAGE;
<html>
<head>
<title>Demo Data</title>
</head>
<link rel=StyleSheet href="http://www.peibd.com/style.css" type="text/css" media="screen">
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
<table width="90%" height="90%" align="center" cellspacing="0" cellpadding="0" border="0"><TR valign="top">
<TD class="category"><br>
A
</td></TR><TR valign="top"><TD class="category">

TOPOFPAGE
#######
open(DATABASE, "datafiles/data.txt") || die "Can't open input";
$count=0;
@data=<DATABASE>;
close (DATABASE);

foreach $data(@data)
{

($Category) = split(/\|/, $data);
push @db_searchresults, $data;
}

foreach $data1(@db_searchresults)
{

chop ($data1);
($Category) = split(/\|/, $data1);
push @db_Category, $Category;

$count++;
$urllink="";
$nextletter=0;

@letters = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', );
}


if("$db_Category[0]" eq ""){ print "<BR><div align=center><b><i>No Entry</b><br></div>";
}

$start = "$in{'start'}";
while ($count) {
$listing[$i] = substr("$db_Category[$i]",0,1);
$letters[$nextletter];

$urllink[$i] = "<a href='../listing/display.cgi?search=1&searchtype=all&searchtext=$db_Category[$i]'>$db_Category[$i]</a>,";

if ("$letters[$nextletter]" eq "$listing[$i]")

{
print qq!
$urllink[$i]
!;
$i++;
--$count;
}
else {
print qq!
</td></TR><TR valign="top">
<TD class="category"><br>
$letters[$nextletter+1]
</td></TR><TR valign="top">
<TD class="category">
!;
$i++;
$nextletter++;
--$count;
}
}

print "</td></TR></table>";

print <<EOF;

</body>
</html>

EOF
#end

##############################################

Now that havnig been said, can someone help me put this in 3 columns


(This post was edited by allan1962 on Jun 4, 2007, 6:32 PM)


Edit Log:
Post edited by allan1962 (Novice) on Jun 4, 2007, 6:32 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives