mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
// Make a MySQL Connection
/* Summary of the valid */
$query = "SELECT sum(punch_stock),sum(die_stock) FROM $tb where code = '$_GET[code]'";
echo $query;
$result = mysql_query($query) or die(mysql_error());
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
$punch=$row[0];$die=$row[1];
echo "<br>Total: punch ".$punch." die ".$die."<br>";
/* Summary of the valid */
$query = "SELECT sum(punch_stock_used),sum(die_stock_used) FROM $tb1 where code = '$_GET[code]'";
echo "<br> ".$query;
$result = mysql_query($query) or die(mysql_error());
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
$punch_used=$row[0];$die_used=$row[1];