如何在不下载的情况下查看pdf?

问题描述 投票:-1回答:1

[大家好,我正在使用select命令从数据库中查看pdf,它正在运行,但是每次刷新页面时,它都会尝试下载所有pdf。我希望它是正常列表,然后单击一下即可下载。

这是我的代码

<?php
function selectFishprice()
{
    try {
        $connection = connect();
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sqlQuery = "SELECT price AS pdf_path, Date FROM upload WHERE id = 1";
        $statement = $connection->query($sqlQuery);
        $statement->setFetchMode(PDO::FETCH_ASSOC);
        $Fishprices = $statement->fetchAll();
        if (!empty($Fishprices)) {
            return $Fishprices;
        } else {
            return NULL;
        }
    } catch (PDOException $exception) {
        die("Error: " . $exception->getMessage());
    }
}

$fishPrices = selectFishprice();
?>
<table id="users">
    <thead>
        <tr>
            <th scope="col">Fish Market Price</th>
            <th scope="col">As of</th>
        </tr>
    </thead>
    <tbody>
<?php
    if (!empty($fishPrices)) {
        foreach ($fishPrices as $fishPrice) {
            $date = strtotime($fishPrice['Date']);
?>
            <tr class="table-primary">
            <td scope="row"><img src="<?= $fishPrice['pdf_path'] ?>"/></td>
            <td scope="row"><?= date('M j Y', $date)?></td>
            <?php
        }
    } else {
?>
        <tr class="table-primary">
            <td class="text-center" colspan="4" scope="row">No records found.</td>
        </tr>
<?php
    }
?>
    </tbody>
</table>

我从网站上读取了使用“标头”的信息,但我不知道该将“标头”放在哪里?任何帮助表示赞赏,谢谢

php pdf view download
1个回答
0
投票

使用anchor tag (i.e. <a>)

anchor tag (i.e. <a>)
© www.soinside.com 2019 - 2024. All rights reserved.