PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 19, 2022

[FIXED] Codeigniter datatable How to link my file column

 February 19, 2022     codeigniter, php     No comments   

Issue

image link

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing