We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,787 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Ask : Direct Displaying PDF File

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

4
Contributors
2
Replies
6 Months
Discussion Span
2 Months Ago
Last Updated
13
Views
sigit_p
Newbie Poster
12 posts since Jun 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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.'">';
LastMitch
Industrious Poster
4,132 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@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.

JorgeM
Industrious Poster
4,007 posts since Dec 2011
Reputation Points: 294
Solved Threads: 544
Skill Endorsements: 115

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0589 seconds using 2.67MB