<?php 
require_once('Connections/localhost.php'); 
mysql_select_db($database_localhost,$localhost);
$productID = $_POST['productID'];
$productType = $_POST['productType'];
if($productType == "productID"){
	$query1 = mysql_query("select * from tbl_introprod where product_ID = '$productID'");
}
else if($productType == "productName"){
	$query = mysql_query("select * from tbl_product where product_NAME = '$productID'");
	$rowID = mysql_fetch_array($query);
	$theid = $rowID['product_ID'];
	$query1 = mysql_query("select * from tbl_introprod where product_ID = '$theid'");
}
else if($productType == "productType"){
	$query1 = mysql_query("select * from tbl_product where product_TYPE = '$productID'");
	$i = 1;
	echo "Y%";
	while($rowType = mysql_fetch_array($query1)){
		if($i <= 10){
			$tempProd = $rowType['product_ID'];
			$result1 = mysql_query("Select * from tbl_introprod where product_ID = '$tempProd'");
			while ($row1=mysql_fetch_array($result1))
			{
				echo "".$row1['product_ID']."%".$rowType['product_NAME']."%".$rowType['product_TYPE']."%".$row1['timeToIn']."%".$row1['expireDay']."%".$row1['product_QUANTITY']."%".$row1['OWNER']."%".$row1['personForHander']."%";
			}
				
		}
	$i = $i + 1;
	}
	echo " a";
}
else if($productType == "Indate"){
	$query1 = mysql_query("select * from tbl_introprod where timeToIn = '$productID'");
}
else if($productType == "expire"){
	$query1 = mysql_query("select * from tbl_introprod where expireDay = '$productID'");
}
else if($productType == "receiver"){
	$query1 = mysql_query("select * from tbl_introprod where personForHander = '$productID'");
}
else if($productType == "owner"){
	$query1 = mysql_query("select * from tbl_introprod where OWNER = '$productID'");
}
else if($productType == "location"){
$wareH = substr($productID, -5, 1);
$location = substr($productID, -4, 4);
	$query1 = mysql_query("select * from tbl_introprod where wareHouse = '$wareH' and location = '$location'");
}
else{
	//$query1 = mysql_query("select * from tbl_product");
}
//$row = mysql_fetch_array($query1);
if($productType == "productType"){}
else{
$i = 1;
echo "Y%";
while ($row=mysql_fetch_array($query1))
{
	if($i <= 10){
			$tempProd = $row['product_ID'];
			$result1 = mysql_query("Select * from tbl_product where product_ID = '$tempProd'");
			while ($row1=mysql_fetch_array($result1))
			{
				$location = $row['wareHouse'].$row['location'];
				echo "".$row1['product_ID']."%".$row1['product_NAME']."%".$row1['product_TYPE']."%".$row['timeToIn']."%".$row['expireDay']."%".$row['product_QUANTITY']."%".$row['OWNER']."%".$row['personForHander']."%".$location."%";
			}
				
	}
	$i = $i + 1;
}
echo " a";
}
//mysql_query("Insert into mydatabase.tbl_user values('$ID','$useremail','$password')");

 //echo "<script language='javascript'>alert(".$row['username'].")</script>";
?>