1.11M Members

Ask : Direct Displaying PDF File

 
0
 

Hi all,...

i've created hyperlink from database to pdf file, my goals when i click the hyperlink then display the pdf file, but the problem is there is a transition page with broken image on the upper left corner and if i place the cursor around the icon the cursor change to hand icon and when i click again the pdf file appears.

so how to make the hyperlink from db direct to pdf file without a transition page/blank page ???

these is my script, previously i use this script for displaying image file (.png)

<?php
    $q=$_GET['id'];
    $con = mysql_connect('localhost', 'test', '123');
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("dm", $con);
    //end of your conn.
    $query = mysql_query("SELECT file FROM 2012 WHERE id = '$q' LIMIT 1") or die(mysql_error());
    while($imglink = mysql_fetch_assoc($query))
{
    echo '<a href="'.$imglink['file'].'"><img src="'.$imglink['file'].'" width="430" height="608" alt="" /></a>';
    }
    ?>  

if i use this script in hyperlink will appear :

http://localhost/dociee-d-l.php?id=L07-09-12

and my hope the hyperlink will be direct to pdf file :

http://localhost/dociee-d-l.php?id=L07-09-12.pdf

thank you

LastMitch
Deleted Member
 
0
 

@sigit_p

and my hope the hyperlink will be direct to pdf file

You can try this way:

 //get file
 $imglink = $_GET["file"] .".pdf";
 //echo out file.pdf
 echo '<a href="'.$imglink.'">';
 
0
 

@sigit_p, you are getting the "broken link" icon because of the image element you have as content for the hyperlink: src="'.$imglink['file']. Based on your code, this is not a source for an image.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article