Jump to content

PHP & Maybe Javascript?


daebat

Recommended Posts

I need to modify the following script to, when clicked on, pop up a download box instead of viewing the jpg image, pdf, etc.

 

<?php
$data = mysql_query("SELECT * FROM flyers ORDER BY id DESC ") or die(mysql_error());

//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
Echo "<div style='float:left;padding-top:15px;'>";
Echo "<table width='225'>";
Echo "<tr><td colspan='2' style='text-align:center;text-transform:uppercase;'><b> ".$info['title'] . "</b></td></tr> ";
Echo "<tr><td colspan='2' style='text-align:center;'><b> ".$info['description'] . "</b></td></tr> ";
Echo "<tr><td colspan='2' style='text-align:center;'><a href='upload/flyers/".$info['image'] ."'><img src='upload/flyers/".$info['thumb'] . "' style='text-align:center;border:none;'></a></td></tr>";

Echo "<tr><td style='vertical-align: middle; text-align:center;font-size:x-small;'>Press Quality PDF</td><td><a href='upload/flyers/".$info['pdf'] . "'><img src='../associates/images/download.png' border='0' width='75'></a><br></td></tr>";
Echo "<tr><td style='vertical-align: middle; text-align:center;font-size:x-small;'>Microsoft Word</td><td><a href='upload/flyers/".$info['word'] . "'><img src='../associates/images/download.png' border='0' width='75'></a><br></td></tr>";

Echo "</table>";
Echo "</div>";


}
?> 

Link to comment
Share on other sites

I would like some help please.

 

You'd use the header() function.

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');

 

A simple example to force download of a PDF rather than display it. But as mentioned, we're not going to write a huge snippet for you, Just going to help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.