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';