<?Php
/*
* @author Istvan Franko
* @copyright 2014
*/
ob_start();
session_start();

if (!isset($_SESSION['cart'])) 
{
  $_SESSION['cart']=array(); 
}
?>

<html>

<head>
<title>Natty Notebooks Inc.</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>

<body>

<div id="container">

	<div id="header">
	<! header picture in css >
	</div>
	
	<div id="navigation">
		<?php include 'navigation-bar.php'; ?>
	</div>
	
<div id="aside">
	<!--Link for navigation-->
	<a href="product-list.php"><p style="text-align:center">Back to list</a></p>	

	<fieldset style="width:85%"><legend>HELP</legend>
	<p>The capabilities of all our items can be found here.</p> 
	<p>We are trying to help you as much as possible, 
	by giving as many pictures and details as we can for all the items.</p> 
	<p>The <span class="red">-Ask about this-</span> link will direct you to one of our employees who will 
	give you more information on the specific item.</p> 
	<p>The <span class="red">-Add to cart-</span> link puts our product in the shopping cart, 
	which our company maintains for 24 hours of their booking.</p>
	</fieldset><br>
</div>

<div id="content">
<br>
<fieldset style="width:95%"><legend>DETAILS</legend>
	
<?php

$con = mysql_connect("localhost","*****","*****");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("university", $con);

//check $id setted or not
//if (!isset($id))
//{
//echo "Sorry, there appears to have been an error when try to get item number.<br>";
//echo "<a href='index.php'><p style='text-align:center'>Go back to home</a></p>";
//exit;
//}


//get the value from the address bar
$id=$_GET['id']; 
if(!is_numeric($id))
{ //check is a number.
echo "Sorry, there appears to have been an error.<br>";
echo "<a href='index.php'><p style='text-align:center'>Go back to home</a></p>";
exit;
}



$query=Mysql_query("SELECT * FROM natty WHERE ItemID=$id ");
$row=mysql_fetch_object($query);
echo mysql_error();


//display the records in a html table
echo "<table border='0' align='center'  cellspacing='5' cellpadding='5' style='width:650px;'>";

echo "
	<tbody>
		<tr bgcolor='#e1e0e0'>
			<td colspan='3' class=border style='width: 640px; text-align: center;'>
				<h2>$row->ItemName</h2> </td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td colspan='1' rowspan='8' class=border style='width: 255px; text-align: center;'>
				<a href='images/$row->ItemPicture1'><img width='250' src='images/$row->ItemPicture1'></img></a></td>
			<td colspan='2' class=border style='width: 375px; height: 40px; text-align: center;'>
				<h3>&#163;$row->ItemPrice</h3></td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Category:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemCategory</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				CPU:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemCpu</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Memory:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemMem</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				HDD:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemHdd</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Screen size:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemScreenSize</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Sowftware:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemOpSys</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Item ID:</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemID</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td colspan='1' rowspan='2' class=border style='width: 255px; text-align: center;'>
";				

//loops if more than 1 picture exit
if ($row->ItemPicture2 != "")
{
echo "<a href='images/$row->ItemPicture2'><img width='60' src='images/$row->ItemPicture2'></img></a>" . " ";
}
else
{
echo "Sorry ... <br>We haven't more picture.";
}

if ($row->ItemPicture3 != "")
{
echo "<a href='images/$row->ItemPicture3'><img width='60' src='images/$row->ItemPicture3'></img></a>" . " ";
}

if ($row->ItemPicture4 != "")
{
echo "<a href='images/$row->ItemPicture4'><img width='60' src='images/$row->ItemPicture4'></img></a>" . " ";
}

if ($row->ItemPicture5 != "")
{
echo "<a href='images/$row->ItemPicture5'><img width='60' src='images/$row->ItemPicture5'></img></a>";
}

//continue display item details in table
echo "			</td>
			<td class=border style='width: 110px; height: 25px;'>
				Middlesbrough</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemInMbro Qty available</td>
		</tr>		
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 110px; height: 25px;'>
				Stockton</td>
			<td class=border style='width: 260px; height: 25px;'>
				$row->ItemInStockton Qty available</td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td class=border style='width: 255px; text-align: center;'>
				<a href='ask-form.php?id=$row->ItemID'><h2>Ask about this</h2></a></td>
			<td colspan='2' rowspan='1' class=border style='width: 375px; text-align: center;'>
				<a href='add-to-cart.php?id=$row->ItemID'><h2>Add to cart</h2></a></td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td colspan='3' class=border style='width: 640px;'>
				<span class='red'>Short Desription: </span><br> $row->ItemShortDesc </td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td colspan='3' class=border style='width: 640px;'>
				<span class='red'>URL: </span><a href='$row->ItemOfficialUrl'</a>$row->ItemOfficialUrl </td>
		</tr>
		<tr bgcolor='#e1e0e0'>
			<td colspan='3' class=border style='width: 640px;'>
				<span class='red'>Description: </span><br> $row->ItemDesc </td>
		</tr>
	</tbody>
</table>
<p>
	&nbsp;</p>
";
ob_end_flush();
?>
</fieldset>

</div>

<div id="footer">
<p align="center">Copyright &#169; Istvan Franko, 2014</p>
</div>


</div>

</body>
</html>
