<?php
include("connect.php");

$ISBN = $_GET["ISBN"];

$result = mysql_query("SELECT * FROM item WHERE ISBN = '$ISBN'");


$row = mysql_fetch_array($result);

echo "<div id='mainpage'>";
echo "<center>";
echo "<h3>Book Detail</h3>";
echo "</div>";

echo "<div id='bookmenu'>";
echo "<table border='0' cellspacing='2' cellpadding='1' bordercolor='black' width='80%'>";

	echo "<tr>";
	echo "<td colspan='3'></td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th colspan='3' style='font-size:15pt'>".$row["itemName"]."</th>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td rowspan='6' weight='20%' align='center'>";
	echo "<img src='$row[itemImage]' height='200' weight='200' style='margin:10 10 10 10'>";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th width='15%'>ISBN:</th>";
	echo "<td width='65%'>".$row["ISBN"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th>Author:</th>";
	echo "<td>".$row["itemAuthor"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th>Publisher:</th>";
	echo "<td>".$row["itemPublisher"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th>Issue Date:</th>";
	echo "<td>".$row["itemDate"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th>Category:</th>";
	echo "<td>".$row["itemCategory"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td align='center'><br/>";
	echo "</td>";
	echo "<th>Price:</th>";
	echo "<td>RM";
	printf("%10.2f",$row["itemPrice"]);
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td align='center'><br/>";
	echo "<th>Order Receive:</th>";
	echo "<td>".$row["itemSales"]."</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td colspan='3'></td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th colspan='3' style='font-size:15pt'><b>Summary:</b></th>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td colspan='3'>".$row["itemSummary"]."</td>";
	echo "</tr>";
	
	echo "</table>";
$result2 = mysql_query("SELECT * FROM temcart WHERE temItem = '$ISBN'");

$num_results = $result2->num_rows;

echo "<table border='0' cellspacing='2' cellpadding='1' bordercolor='black' width='80%'>";
	echo "<tr>";
	echo "<th colspan='4' style='font-size:15pt'><b>Preorder Summary:</b></th>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<th>No</th>";
	echo "<th>Customer</th>";
	echo "<th>Quantity</th>";
	echo "<th>Total Price</th>";
	echo "</tr>";
	
	for($i=0; $i<$num_results; $i++)
{
	$row2 = mysql_fetch_array($result2);
	echo "<tr>";
	echo "<td>".($i + 1)."</td>";
	echo "<td>".$row2["temID"]."</td>";
	echo "<td>".$row2["temQuantity"]."</td>";
	echo "<td>RM ";
	printf("%10.2f",$row2["temPrice"]);
	echo "</td>";
	echo "</tr>";
	}

echo "</table>";
echo "</div>";
echo "</center>";

$db = mysql_close();

?>