//header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('Asia/Bangkok');
$date = date('Y-m-d H:i:s');
ini_set('max_execution_time', 300);
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$barcode = $_POST['barcode'];
$store = $_POST['store'];
}
else
{
$barcode = $_GET['barcode'];
$store = $_GET['store'];
}
include("connect.php");
mysqli_query($mysqli,"SET character_set_results=utf8");
mysqli_query($mysqli,"SET character_set_client=utf8");
mysqli_query($mysqli,"SET character_set_connection=utf8");
if(strlen($store)>0)
{
$result = $mysqli->query("SELECT * FROM usthstores WHERE barcode = '$barcode' AND store = '$store'");
$num_rows = mysqli_num_rows($result);
if($num_rows==0)
$result = $mysqli->query("SELECT * FROM usthstores WHERE barcode = '$barcode'");
}
else
{
$result = $mysqli->query("SELECT * FROM usthstores WHERE barcode = '$barcode'");
}
$num_rows = mysqli_num_rows($result);
if($num_rows>0)
{
$row=mysqli_fetch_row($result);
$productname = $row[1];
$price = $row[2];
$amount = $row[4];
$store = trim($row[6]);
if($price>0)
{
if(strpos(" Kroger,Albertsons,Safeway",$store)==0)
$price = $price/32.5;
$price = number_format($price, 2, '.', '');
echo $productname." Price:".strval($price)." ".$store;
}
}
?>