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
https://forums.phpfreaks.com/topic/190110-php-maybe-javascript/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.