Issue
Good day everyone i would like to ask if there is someone had a idea on how to make that specific column a link so that the user can download that pdf file.
This my Datatable
<table id="example" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
<tr>
<th class="text-center align-middle">Control Number</th>
<th class="text-center align-middle">Attached Form</th>
<th class="text-center align-middle">P.R. Date.</th>
<th class="text-center align-middle">ABC/PR Amount.</th>
<th class="text-center align-middle">File</th>
</tr>
</thead>
<tbody>
<?php
if($logs){
foreach ($logs as $log){
?>
<tr>
<td class="<?php
if (empty($log->control_number)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->control_number)) {
echo $log->control_number;
}
?>
</td>
<td class="<?php
if (empty($log->category)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->category)) {
echo $log->category;
}
?>
</td>
<td class="<?php
if (empty($log->pr_date)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->pr_date)) {
echo date("m/d/Y", strtotime($log->pr_date));
}
?>
</td>
<td class="<?php
if (empty($log->approve_budget )) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->approve_budget )) {
echo $log->approve_budget ;
}
?>
</td>
//Here is the column that i want to be a link to be downloaded
<td class="<?php
if (empty($log->file)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->file )) {
echo $log->file ;
}
?>
</td>
////////////////////////////////////////////////////////////////////////
</tr>
<?php
}
}
?>
</tbody>
</table>
Solution
just create an anchor link
<?php
if (!empty($log->file )) {
echo '<a href="'.$log->file.'" target="_blank" >'.$log->file.'</a>';
}
Answered By - Hammad Ahmed khan
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.