<?
//หาค่า District Seal Before (B_ABCD)
$strSQL = "SELECT MIN(UN_RETORT) as UN_RETORT1 FROM tUN_SPSTRENGTH WHERE LINE='$line' AND NAME='$NAME' AND DATE='DATE' AND MONTH='$month' and YEAR='$year' AND PS_TYPE='B_ABCD' ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult= mssql_fetch_array($objQuery)){
$MIN = $objResult["UN_RETORT1"];
}
echo $CMIN = number_format($MIN, 2);
?>
<?
function shift_max(&$arr){
$max = max($arr);
foreach($arr as $key => $val)
if($val < $max)
unset($arr[$key]);
}
//หาค่า District Seal Before (B_ABCD)
$strSQL = "SELECT MIN(UN_RETORT) as UN_RETORT1 FROM tUN_SPSTRENGTH WHERE LINE='$line' AND NAME='$NAME' AND DATE='DATE' AND MONTH='$month' and YEAR='$year' AND PS_TYPE='B_ABCD' ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult= mssql_fetch_array($objQuery)){
$MIN[] = number_format($objResult["UN_RETORT1"],2);
}
foreach($MIN as $val){
if(!isset($b[$val]))$b[$val]=1;
else ++$b[$val];
}
arsort($b);
shift_max($b);
echo "<hr />";print_r($b); //เอาอาร์เรย์ $b ไปใช้น่ะครับ
?>
<?php session_start();?>
<?php require_once('includes/connect.php'); ?>
<?php require_once('includes/function.php'); ?>
<?
$month = $_REQUEST['month'];
$year= $_REQUEST['year'];
$line= $_REQUEST['line'];
?>
<?
$strSQL = "SELECT DISTINCT (DATE) ,SHIFT,NAME from tSPSTRENGTH
inner join tSU_SPSTRENGTH on tSPSTRENGTH.NAME = tSU_SPSTRENGTH.SNAME
where MONTH='$month' and YEAR='$year' AND LINE='$line' order by DATE ASC ,SHIFT ASC";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mssql_fetch_array($objQuery))
{
?>
<?
//หาค่า District Seal Before (B_ABCD)
$strSQL_BMI = "SELECT MIN(UN_RETORT) as UN_RETORT1 FROM tUN_SPSTRENGTH WHERE LINE='$line' AND NAME='".$objResult["NAME"]."' AND DATE='".$objResult["DATE"]."' AND MONTH='$month' and YEAR='$year' AND PS_TYPE='B_ABCD' ";
$objQuery_BMI = mssql_query($strSQL_BMI) or die ("Error Query [".$strSQL_BMI."]");
while($objResult_BMI = mssql_fetch_array($objQuery_BMI)){
$MIN_BMI = $objResult_BMI["UN_RETORT1"];
}
echo $CMIN_BMI = number_format($MIN_BMI , 2);
}
?>
<?
function shift_max(&$arr){
$max = max($arr);
foreach($arr as $key => $val)
if($val < $max)
unset($arr[$key]);
}
//หาค่า District Seal Before (B_ABCD)
$strSQL = "SELECT MIN(UN_RETORT) as UN_RETORT1 FROM tUN_SPSTRENGTH WHERE LINE='$line' AND NAME='$NAME' AND DATE='DATE' AND MONTH='$month' and YEAR='$year' AND PS_TYPE='B_ABCD' ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult= mssql_fetch_array($objQuery)){
$MIN[] = number_format($objResult["UN_RETORT1"],2);
}
$b = array_count_values($MIN);
arsort($b);
shift_max($b);
echo "<hr />";print_r($b); //เอาอาร์เรย์ $b ไปใช้น่ะครับ
?>