Perfect!
Text::ASCIITable works great and does most things for me.
In either ascii or in html table format...
#!/eng/local/bin/perl
# table maker
require '/home/top/hfranks/perl/ASCIITable.pm';
# database hack
require "../mysql_handeler.pl";
require "../template.pl";
#new table
$t = new Text::ASCIITable;
$user="hfranks";
@id=mysql_handeler('select uid from users_student where name="'.$user.
+'";');
$uid=$id[1];
#mysql statements
@res=mysql_handeler('select * from EECS2550 where uid="'.$uid.'";');
chomp @res;
#column title
@top=split(/ /, shift(@res));
#remove 2 unwanted auto_increment fields
shift (@top);
shift (@top);
$t->setCols(\@top);
#get rows
foreach $line (@res){
chomp $line;
@ary = split(/ /, $line);
#remove two unwanted auto_increment fields
shift (@ary);
shift (@ary);
$t->addRow(@ary);
}
#print it
#normal ascii output
#$cOntent .= $t->draw();
#advanced html output
$cOntent.=$t->draw(
['<table border="1">','','',''], # <table><tr></tr>
['<tr><td>','</td></tr>','</td><td>'],
['','','',''],
['<tr><td>','</td></tr>','</td><td>'],
['','</table>','',''],
);
my $template = "../template.html";
my %gTokens=();
my $key="<!--something-->";
$gTokens{"$key"} = $cOntent;
&SendTemplate($template,%gTokens);
html result:
test1 | test2 | test3 | quiz1 | homework | final |
100 | 100 | 100 | 10 | 100 | 100 |
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.