Hi, your code looks good. Its working fine for me with hyperlink. In DBIx::XHTML_Table module, all the column names are in same case (lower or upper) as of database field name.
Look the code:
use DBIx::XHTML_Table;
# database credentials - fill in the blanks
my ($data_source,$usr,$pass) = ();
my $table = DBIx::XHTML_Table->new('DBI:mysql:project', '', '');
$table->exec_query("select * from test");
$table->modify(table => {
width => '100%',
cellspacing=> '2',
cellpadding=>'5',
'border-style' => 'inset',
'border-width' => 'thin',
});
$table->modify(th => {
style => {
color => '#FFFAF0',
background => '#4682B4',
'text-align' => 'center',
'text-transform'=> 'uppercase',
}
},'head');
$table->modify(tr => {
style => {
background => ['#B0C4DE','#F0F8FF'],
}
});
$table->modify(td => {
style => {
'text-align' => 'left',
'white-space' => 'nowrap',
}
});
$table->modify(td => {
style => {
'text-align' => 'center',
'white-space' => 'nowrap',
}
},['id']);
$table->modify(th => {
style => 'background: #FFF0F5'
},'id');
$table->map_cell( sub{
my $datum = shift;
return qq|<a href="http://sctesrv.india/cgi/project/viewpro
+jectdetail.cgi?projectid=P-$datum">"$datum"</a>|;
}, ['id']);
print $table->output;
Output as:
<table width="100%" cellspacing="2" cellpadding="5" border-width="thin
+" border-style="inset">
<thead>
<tr style="background: #B0C4DE;">
<th style="background: #FFF0F5">Id</th>
<th style="text-align: center; text-transform: uppercase; colo
+r: #FFFAF0; background: #4682B4;">Value</th>
</tr>
</thead>
<tbody>
<tr style="background: #F0F8FF;">
<td style="text-align: center; white-space: nowrap;"><a href="
+http://sctesrv.india/cgi/project/viewprojectdetail.cgi?projectid=P-1"
+>"1"</a></td>
<td style="text-align: left; white-space: nowrap;">hello</td>
</tr>
<tr style="background: #B0C4DE;">
<td style="text-align: center; white-space: nowrap;"><a href="
+http://sctesrv.india/cgi/project/viewprojectdetail.cgi?projectid=P-2"
+>"2"</a></td>
<td style="text-align: left; white-space: nowrap;">googbye</td
+>
</tr>
<tr style="background: #F0F8FF;">
<td style="text-align: center; white-space: nowrap;"><a href="
+http://sctesrv.india/cgi/project/viewprojectdetail.cgi?projectid=P-3"
+>"3"</a></td>
<td style="text-align: left; white-space: nowrap;">friend</td>
</tr>
</tbody>
</table>
Regards,
Velusamy R.
eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';
-
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.