首页 > 解决方案 > 通过 PHP 将保存在 Desktop 文件夹中的文件链接到已存在的项目列表

问题描述

以下代码以列表的形式从 mysql 表中获取大约 100 条判断记录,其中包含案例编号、标题等。我在桌面上有一个单独的文件夹,其中包含这些判断的 pdf 文件。此文件夹或其中的文件与 mysql 表没有链接。有没有什么办法,当用户点击任何一个案例号时,判断该案例号。将在浏览器中或通过 pdf 阅读器打开。

我不知道如何将桌面文件夹中的文件动态链接到列表中的项目,这意味着单击列表中的每个项目都应该打开与其对应的pdf文件。

<?php

        $conn = mysqli_connect('localhost', 'root', '', '');

        $sql="SELECT case when ordertype=1 then 'Judgement' else 
                'Order' end ordertype, casetype, caseno, year, petitioner, 
                respondent, firstcoram, secondcoram, thirdcoram, fourthcoram, 
                fifthcoram, cavon, pronouncementdate, questionoflaw FROM `cav` 
                WHERE writtenby ='1' and ordertype='1' and  
                CAST(`pronouncementdate` AS CHAR(10)) != '0000-00-00' ORDER BY 
                pronouncementdate ASC";
        $query = $conn->query($sql);
        $result = mysqli_query($conn, $sql);    
        $i=0;
        $date = date('d-m-Y');  
        echo '<BR><BR><BR><BR>

        <h2 align="center">Judgement delivered by       as on 
                '.$date.'</h2>
        <CENTER><table border=".05" cellspacing="0" cellpadding="3">
        <tr>
            <th>S.No.</th>
            <th>Case No.</th>
            <th width="17%" >Cause Title</th>
            <th>Question of Law</th>
            <th>Coram</th>
            <th>Judgment/ Order</th>
            <th>CAV Date</th>
            <th>Judgment Pronounced On</th>
            </tr> ';

        while($row = mysqli_fetch_array($result)){
        $i++;
        echo"
        <tr>
            <td>".$i."</td>
            <td>".$row["casetype"]." ".$row["caseno"]."/".$row["year"]." 
                </td>
            <td>".$row["petitioner"]."<br>Vs.<br>".$row["respondent"]." 
                </td>
            <td>".$row["questionoflaw"]."</td>
            <td>".$row["firstcoram"]."<br>".$row["secondcoram"]." 
                <br>".$row["thirdcoram"]."<br>".$row["fourthcoram"]." 
                <br>".$row["fifthcoram"]."</td>
            <td>".$row["ordertype"]."</td>
            <td>".date_format(date_create($row["cavon"]),'d-m-Y')."</td>
            <td>".date_format(date_create($row["pronouncementdate"]),'d-m- 
                Y')."</td>
        </tr>
        ";
        }
        echo"
        </CENTER></table>";
        ?>

我希望案例编号可以点击(具有超链接),并且当用户单击列表中出现的任何案例编号时,它应该打开位于我桌面上可用文件夹中的相应 pdf 文件。

标签: phphtmlmysqlhyperlink

解决方案


推荐阅读