0

So I have PHP/MySQL setup where I can upload a blob file. What I want to do is to be able to download the file from my website. I already have it setup where I can upload it from a form, but I am running into trouble trying to pull it from the database and download it. Here is the code where I want to show it, what I want is to add another td that contains a link to download the file:

    <body>
<?php
require_once "connect.php";
include "header.php";

try
{
    $sql = 'SELECT * FROM items WHERE ID = :ID';
    $stmt = $pdo->prepare($sql);
    $stmt->bindValue(':ID', $_GET['ID']);
    $stmt->execute();
    $result = $stmt->fetchAll();
    echo '<table>';
    foreach ($result as $row)
    {
        echo    '   <tr><td><th>ID</th></td><td>'.$row['ID'] . '</td></tr>
                    <tr><td><th>Title</th></td><td>'.$row['title'] . '</td></tr>
                    <tr><td><th>Summary</th></td><td>'.$row['summary'] . '</td></tr>
                    <tr><td><th>Author\'s First Name</th></td><td>'.$row['afirst'] . '</td></tr>
                    <tr><td><th>Author\'s Last Name</th></td><td>'.$row['alast'] . '</td></tr>';
    }
    echo '</table>';


}//try
catch (PDOException $e)
{
    echo 'Error fetching users: <br />ERROR MESSAGE:<br />' .$e->getMessage();
    exit();
}
include "footer.php";
?>
</body>
</html>

I have tried using $_PHP['SELF'] but have not had any luck.

Cave Johnson
  • 6,499
  • 5
  • 38
  • 57
  • You can't link to data in the database. You have to create a new PHP page that runs a query, fetches the data and echos it. You also should set your headers correctly (Content-Type and Content-Length). – mpen Mar 04 '16 at 01:02
  • Just for future reference: phpmyadmin is a tool that let's you interact with your database. Your application is using php and mysql, not phpmyadmin. – Cave Johnson Apr 27 '16 at 01:41

0 Answers0