<?
ini_set('max_execution_time',60000000); // 60 seconds for max execution time
include "connect.php";
mysql_query("SET NAMES UTF8");
$start="2008-01-01";
$finish="2008-01-15";
$sql0="Select pra_id,pra_date from prawat where pra_date Between '$start' and '$finish'";
$result0=mysql_db_query($dbname,$sql0);
$Num0=mysql_num_rows($result0);
while($rs0=mysql_fetch_array($result0)) {
$id0=$rs0[pra_id];
//echo "$id0<br>";
$sql1="Select maec_id,maec_no From maechee Where maec_id='$id0' and maec_no='1' ";
$result1=mysql_db_query($dbname,$sql1);
$num1=mysql_num_rows($result1);
while($rs1=mysql_fetch_array($result1)) {
$id1=$rs1[maec_id];
//echo "$id1<br>";
$sql2="SELECT DISTINCT pra_prov, COUNT(pra_prov) AS pra_prov2 FROM prawat where pra_sex='หญิง' and pra_id='$id1' GROUP BY pra_prov";
$result2=mysql_db_query($dbname,$sql2);
$Num2=mysql_num_rows($result2);
while($rs2=mysql_fetch_array($result2)){
$prov=$rs2['pra_prov'];
$prov2=$rs2['pra_prov2'];