Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
187 views
in Technique[技术] by (71.8m points)

php - Codeigniter datatable How to link my file column

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>
question from:https://stackoverflow.com/questions/65895460/codeigniter-datatable-how-to-link-my-file-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

just create an anchor link

 <?php
  if (!empty($log->file )) {
   echo '<a href="'.$log->file.'" target="_blank" >'.$log->file.'</a>';

  }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...