|
Everything except image - Scripts 14.7 / 14.8 - solved four years ago | Registered: four years ago Posts: 17 |
<td style="text-align:left;color:#000000;background-color:#ffffcc;" colspan="3"> <!-- Content starts here! --><div style="text-align:center;" ><br /> <b style="font-size:110%;">Chinese Temple</b><br />by Chon Dou <br />16 x 12 <br />$375.00 <a href="add_cart.php?pid=1">Add to Cart</a> </div> <br /><div style="text-align:center;"> <img src="show_image.php?image=bignchs.jpg" width="1080" height="632" alt="Chinese Temple" /> <br />Chinese Temple </div><!-- Script 14.4 - footer.html --> <!-- Content starts here! --> <br /></td>
<?php # Script 14.7 - view_print.php
// This page displays the details for a particular print.
$problem = FALSE; // Assume no problem.
if (isset($_GET['pid'])) { // Make sure there's a print ID.
$pid = (int) $_GET['pid'];
require_once ('../../mysql_connect.php'); // Connect to the database.
$query = "SELECT CONCAT_WS(' ', first_name, middle_name, last_name) AS name, print_name, price, description, size, image_name FROM artists, prints WHERE artists.artist_id = prints.artist_id AND prints.print_id = $pid";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1) { // Good to go!
// Fetch the information.
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
// Start the HTML page.
$page_title = $row['print_name'];
include ('./includes/header.html');
// Display a header.
echo "<div style=\"text-align:center;\" ><br />
<b style=\"font-size:110%;\">{$row['print_name']}</b><br />by
{$row['name']}
<br />{$row['size']}
<br />\${$row['price']}
<a href=\"add_cart.php?pid=$pid\">Add to Cart</a>
</div><br />";
// Get the image information and display the image.
if ($image = @getimagesize ("../../uploads/{$row['image_name']}")) {
echo "<div style=\"text-align:center;\"><img src=\"show_image.php?image={$row['image_name']}\" $image[3] alt=\"{$row['print_name']}\" />";
} else {
echo "<div style=\"text-align:center;\">No image available.";
}
echo "<br />{$row['description']}</div>";
} else { // No record returned from the database.
$problem = TRUE;
}
mysql_close(); // Close the database connection.
} else { // No print ID.
$problem = TRUE;
}
if ($problem) { // Show an error message.
$page_title = 'Error';
include ('./includes/header.html');
echo '<div style=\"text-align:center;\">This page has been accessed in error!</div>';
}
// Complete the page.
include ('./includes/footer.html');
?><?php # Script 14.8 - show_image.php
// This page retrieves and shows an image.
// Check for an image name.
if (isset($_GET['image'])) {
// Full image path:
$image = "../../uploads/{$_GET['image']}";
// Check that the image exists and is a file.
if (file_exists($image) && (is_file($image))) {
$name = $_GET['image'];
} else {
$image = './images/unavailable.gif';
$name = 'unavailable.gif';
}
} else { // No image name.
$image = './images/unavailable.gif';
$name = 'unavailable.gif';
}
// Get the image information.
$ft = mime_content_type($image);
$fs = filesize($image);
// Send the file.
header ("content-type: $ft\n");
header ("content-disposition: inline; filename=\"$name\"\n";
header ("content-length: $fs\n");
readfile ($image);
?>|
Re: Everything except image - Scripts 14.7 / 14.8 four years ago | Registered: four years ago Posts: 17 |
|
Re: Everything except image - Scripts 14.7 / 14.8 - not solved after all: still need help... four years ago | Registered: four years ago Posts: 17 |
|
Re: Everything except image - Scripts 14.7 / 14.8 - not solved after all: still need help... four years ago | Registered: four years ago Posts: 16 |
|
Re: Everything except image - Scripts 14.7 / 14.8 - php.ini four years ago | Registered: four years ago Posts: 16 |