<?php

session_start();

if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");



$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");


$item_code  = $_GET['item_code'];if ($item_code == ""){$item_code = $_POST["item_code"];}
$frm  = $_GET['frm'];if ($frm == ""){$frm = $_POST["frm"];}
print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<title>Uploaded Picture</title>

</head>
<body >
<form name='picture' method='post' action=''>

HERE;

echo"<table border='0' style='table-layout:fixed'>
	<tr bgcolor='#DDDDDD'>
	<td align='center' ><span class='style16'>";
//if($frm == 2)	echo "Customer Code : ";
if($frm == 2) {echo "Item Code : ";
echo $item_code;
}
 echo " </span></td></tr>";
echo"<tr>";	
	
$imgsrc = "uploads/".get_itemimage($item_code,$frm,$connection);
echo"<img src='$imgsrc' width='850' height='400'></img>";
echo'</td></tr>';

echo"</tr>";
echo"</table>";
print <<<HERE
</form>
</body>

HERE;

function get_itemimage($item_code,$frm,$connection){
	if($frm == 2) 
	$query="select contact_photo from CustomerContactInfo where contactinfo_id='".$item_code."'";
else	
	$query="select item_picture from items where item_code='".$item_code."'";

$result=mysql_query($query,$connection);
$row=mysql_fetch_row($result);

$image = $row[0]; 
return $image;
}
?>	