Script 19.7 View Print

Output
title home page view the prints view your cart

This page has been accessed in error!

© 2014 Copyright...
Source
<?php # Script 19.7 - view_print.php
// This page displays the details for a particular print.
ob_start();
$row = FALSE; // Assume nothing!

if (isset($_GET['pid']) && filter_var($_GET['pid'], FILTER_VALIDATE_INT, array('min_range' => 1)) ) { // Make sure there's a print ID!

	$pid = $_GET['pid'];
	
	// Get the print info:
	require (CONNECT_OOP); // Connect to the database.
	$q = "SELECT CONCAT_WS(' ', first_name, middle_name, last_name) AS artist, print_name, price, description, size, image_name FROM sc_artists, sc_prints WHERE sc_artists.artist_id=sc_prints.artist_id AND sc_prints.print_id=$pid";
	$r = mysqli_query ($link, $q);
	if (mysqli_num_rows($r) == 1) { // Good to go!

		// Fetch the information:
		$row = mysqli_fetch_array ($r, MYSQLI_ASSOC);
	
		// Start the HTML page:
		$page_title = $row['print_name'];
		include ('includes/header.html');
	
		// Display a header:
		echo "<div align=\"center\">
		<b>{$row['print_name']}</b> by 
		{$row['artist']}<br />";

		// Print the size or a default message:
		echo (is_null($row['size'])) ? '(No size information available)' : $row['size'];

		echo "<br />\${$row['price']} 
		<br/><a href=\"index.php?chapter=19&script=19.9&pid=$pid\">Add to Cart</a>
		</div><br />";
	
		// Get the image information and display the image:
		if ($image = @getimagesize (SITE_URL."/exercises/19/images/{$row['image_name']}")) {
			echo "<div><img src='".SITE_URL."/exercises/19/images/".$row['image_name']."'  $image[3] alt='{$row['print_name']}' /></div>";	
		} else {
			echo "<div>No image available.</div>\n"; 
		}
		
		// Add the description or a default message:
		echo '<br /><p align="center">' . ((is_null($row['description'])) ? '(No description available)' : $row['description']) . '</p>';
	
	} // End of the mysqli_num_rows() IF.
	
	mysqli_close($link);

} // End of $_GET['pid'] IF.

if (!$row) { // Show an error message.
	$page_title = 'Error';
	include ('includes/header.html');
	echo '<div align="center">This page has been accessed in error!</div>';
}

// Complete the page:
include ('includes/footer.html');
ob_end_flush();
?>