Okay here we go:
Page 1
<?php
include '../library/include.php'; // connect to db
$query = "SELECT id, fullname, receipt, height, width, filename, date FROM artist";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "No Contributors <br>";
}
else
{
while(list($id, $fullname, $receipt, $height, $width, $filename, $date) = mysql_fetch_array($result))
{
if ($saved == '1') { $saved = YES; } else { $saved = NO; } // dont worry about this :)
?>
<table>
<tr>
<td>
<a href="javascript:void(0);" onclick="javascript:window.open('...address..../view_image.php?id=<?php echo $id; ?>','_new','width=<?php echo $width; ?>, height=<?php echo $height; ?>');" title="Contribution Image">Image</a>
</td>
</tr>
</table>
<?
}
}
mysql_close();
?>
Creates a popup widow to the size of the image (image sizes are in the db as height and width - irrelevant)
This is the code to the page that pops up:
<?php
$id = $_GET['id'];
include '../library/include.php';
$query = "SELECT id, receipt, filepath, filename FROM artist WHERE id='$id'";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "No Image Selected <br />\n";
echo "<a href=\"javascript:window.close();\">Close</a>";
}
else
{
$query = "SELECT filename, filetype, filesize, filepath FROM artist WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($filename, $filetype, $filesize, $filePath) = mysql_fetch_array($result);
header("Content-Disposition: unspecified; filename=TwoDollarArt");
header("Content-length: $filesize");
header("Content-type: $filetype");
readfile($filePath);
mysql_close();
exit;
}
?>
the directory of this code is
/www/<username>/public_html/theart/
the directory of the image is
/www/<username>/tmp/theart/
so that is why im using headers, to get to the image... that code there works, but it DOWNLOADS it, i just want it to view.. and if they do "save it" they wont get the name of the image, because it is named as a unique and important number... eg a receipt number or something...