<?PHP function show_arrow($a,$b) { $b_arr=str_split($b); if(in_array('-',$b_arr)) { $val=explode('-',$b); if($a<$val[0]) return "↓"; elseif($val[1]<$a) return "↑"; } if(in_array('>',$b_arr)) { $val=explode('>',$b); if($val[1]>$a) return "↓"; } if(in_array('<',$b_arr)) { $val=explode('<',$b); if($val[1]<$a) return "↑"; } } //function 人数的方法
function twoArraround($array){ $arr_Num=count($array); for($i=0;$i<$arr_Num;$i++){ foreach($array[$i] as $key => $value){ $new_Arr[$key."_".$i]=$value; } } return $new_Arr; }
function sata_Arr($database_name,$condition,$sex,$rate,$db_con){//数据库字段、条件(XX and XX)、性别(男、女)、比率(Y\N)
$query="SELECT ".strtolower(substr($database_name,0,1)).".*,p.Patiant_Sex,p.Patiant_Age FROM ".$database_name." ".strtolower(substr($database_name,0,1)).",Patiant p WHERE ".strtolower(substr($database_name,0,1)).".Patiant_ID=p.Patiant_ID"; if($condition!=""){ $query_str=" and ".$condition; $query=$query.$query_str; } //echo $query;
$result=$db_con->db_query($query); $data=$db_con->loadObjectList($result); $CON_Arr=array_count_values(twoArraround($data)); //echo "";
//print_r($CON_Arr);
if($rate=='Y'){ $num_All = (int) ($CON_Arr["男"]+$CON_Arr["女"]); $num_Rate=(float) (($CON_Arr[$sex]/$num_All)*100); return $num_Rate; } else{ if($sex!="男" && $sex!="女"){ $num_All = (int) ($CON_Arr["男"]+$CON_Arr["女"]); } else{ $num_All = (int) $CON_Arr[$sex]; } return $num_All; } } ?>
|