ช่วยแนะนำหน่อยคับ ต้องการให้มันออกมาสวยคับ ไม่รุ้จะต้องทำไงดี
ขอโทษทีคับ นี้โค๊ดคับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
$count_male_all = mysql_result($query,0,'count_male_all'); // ผู้ชายทั้งหมด
echo "<p><strong>เพศชาย มีทั้งหมด ".$count_male_all." คน </strong></p>";
$count_male_20 = mysql_result($query,0,'count_male_20'); // ผู้ชายผอม
echo " - อยู่ในเกณฑ์ผอม ".$count_male_20." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_25 = mysql_result($query,0,'count_male_25'); // ผู้ชายปกติ
echo " - อยู่ในเกณฑ์ปกติ ".$count_male_25." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_29 = mysql_result($query,0,'count_male_29'); // ผู้ชายอ้วน
echo " - อยู่ในเกณฑ์อ้วน ".$count_male_29." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_mex = mysql_result($query,0,'count_male_mex'); // ผู้ชายอ้วนมากๆ
echo " - อยู่ในเกณฑ์อ้วนมากๆ ".$count_male_mex." คน "; // ผู้ชายทั้งหมด ...
$count_female_all = mysql_result($query,0,'count_female_all'); // ผู้หญิงทั้งหมด
echo "<p><strong>เพศหญิง มีทั้งหมด ".$count_female_all." คน</strong></p>"; // ผู้หญิงทั้งหมด ...
$count_female_20 = mysql_result($query,0,'count_female_20'); // ผู้หญิงผอม
echo " - อยู่ในเกณฑ์ผอม ".$count_female_20." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_25 = mysql_result($query,0,'count_female_25'); // ผู้หญิงปกติ
echo " - อยู่ในเกณฑ์ปกติ ".$count_female_25." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_29 = mysql_result($query,0,'count_female_29'); // ผู้หญิงอ้วน
echo " - อยู่ในเกณฑ์อ้วน ".$count_female_29." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_mex = mysql_result($query,0,'count_female_mex'); // ผู้หญิงอ้วนมากๆ
echo " - อยู่ในเกณฑ์อ้วนมากๆ ".$count_female_mex." คน"; // ผู้ชายทั้งหมด ...
}
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
$count_1to12_all = mysql_result($query,0,'count_1to12_all'); // อายุ 0-12 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 0 - 12 มีทั้งหมด ".$count_1to12_all." คน "; //
$count_1to12_20 = mysql_result($query,0,'count_1to12_20'); // อายุ 0-12 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_1to12_20. " คน ";
$count_1to12_25 = mysql_result($query,0,'count_1to12_25'); // อายุ 0-12 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_1to12_25. " คน ";
$count_1to12_29 = mysql_result($query,0,'count_1to12_29'); // อายุ 0-12 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_1to12_29. " คน ";
$count_1to12_mex = mysql_result($query,0,'count_1to12_mex'); // อายุ 0-12 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_1to12_mex. " คน <br><br>";
//13 - 19
$count_13to19_all = mysql_result($query,0,'count_13to19_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 13 - 19 มีทั้งหมด ".$count_13to19_all." คน "; //
$count_13to19_20 = mysql_result($query,0,'count_13to19_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_13to19_20. " คน ";
$count_13to19_25 = mysql_result($query,0,'count_13to19_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_13to19_25. " คน ";
$count_13to19_29 = mysql_result($query,0,'count_13to19_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_13to19_29. " คน ";
$count_13to19_mex = mysql_result($query,0,'count_13to19_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_13to19_mex. " คน<br><br>";
//20 - 54
$count_20to54_all = mysql_result($query,0,'count_20to54_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 20 - 54 มีทั้งหมด ".$count_20to54_all." คน "; //
$count_20to54_20 = mysql_result($query,0,'count_20to54_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_20to54_20. " คน ";
$count_20to54_25 = mysql_result($query,0,'count_20to54_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_20to54_25. " คน ";
$count_20to54_29 = mysql_result($query,0,'count_20to54_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_20to54_29. " คน ";
$count_20to54_mex = mysql_result($query,0,'count_20to54_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_20to54_mex. " คน<br><br>";
//55 - 100
$count_55to100_all = mysql_result($query,0,'count_55to100_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 55 - 100 มีทั้งหมด ".$count_55to100_all." คน "; //
$count_55to100_20 = mysql_result($query,0,'count_55to100_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_55to100_20. " คน ";
$count_55to100_25 = mysql_result($query,0,'count_55to100_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_55to100_25. " คน ";
$count_55to100_29 = mysql_result($query,0,'count_55to100_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_55to100_29. " คน ";
$count_55to100_mex = mysql_result($query,0,'count_55to100_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_55to100_mex. " คน<br>";
}
?>
</div></td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
Date :
2010-08-08 20:04:42
By :
เด็กไม่เก่ง
ขอร้่องงงงงงงงงงละคับ ผมต้องการจริๆงคับ
Date :
2010-08-08 20:46:04
By :
เด็กไม่เก่ง
พี่ๆคับช่วยสน่อยคับ
Date :
2010-08-09 10:09:47
By :
เด็กมัยเก่ง
ทำไงดี พี่ๆไม่ช่วยสอนผมคับ
Date :
2010-08-09 14:08:25
By :
เด็กไม่เก่ง
ทไงดัคับ ให้มันแสดงออกมาเป็นดังที่ถามไว้คับ ช่วยด้วยคับบบบบบบบบบบบบบบบ
Date :
2010-08-09 15:11:45
By :
เด็กไม่เก่ง
พี่ๆคับ ช่วยยยยยยยยยยยยยยด้วยยยยยยยยยยยยยยยยยยย
Date :
2010-08-09 22:55:09
By :
เด็กไม่เก่ง
แก้ไข script เดิมให้นะครับเด๋วไม่เข้าใจเอา
ไม่ได้หรือติดปัญหาก็ลองถามมาใหม่นะครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style>
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td>
<!--แก้ไขเป็น jummenu-->
<select name="selects" id="selects" onchange="MM_jumpMenu('parent',this,0)">
<option value="0">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$selects = $_POST['selects']; //การสร้างตัวแปรพยายามอย่าใช้ keyword นะครับ
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($selects=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
$count_male_all = mysql_result($query,0,'count_male_all'); // ผู้ชายทั้งหมด
echo "<p><strong>เพศชาย มีทั้งหมด ".$count_male_all." คน </strong></p>";
$count_male_20 = mysql_result($query,0,'count_male_20'); // ผู้ชายผอม
echo " - อยู่ในเกณฑ์ผอม ".$count_male_20." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_25 = mysql_result($query,0,'count_male_25'); // ผู้ชายปกติ
echo " - อยู่ในเกณฑ์ปกติ ".$count_male_25." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_29 = mysql_result($query,0,'count_male_29'); // ผู้ชายอ้วน
echo " - อยู่ในเกณฑ์อ้วน ".$count_male_29." คน<br>"; // ผู้ชายทั้งหมด ...
$count_male_mex = mysql_result($query,0,'count_male_mex'); // ผู้ชายอ้วนมากๆ
echo " - อยู่ในเกณฑ์อ้วนมากๆ ".$count_male_mex." คน "; // ผู้ชายทั้งหมด ...
$count_female_all = mysql_result($query,0,'count_female_all'); // ผู้หญิงทั้งหมด
echo "<p><strong>เพศหญิง มีทั้งหมด ".$count_female_all." คน</strong></p>"; // ผู้หญิงทั้งหมด ...
$count_female_20 = mysql_result($query,0,'count_female_20'); // ผู้หญิงผอม
echo " - อยู่ในเกณฑ์ผอม ".$count_female_20." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_25 = mysql_result($query,0,'count_female_25'); // ผู้หญิงปกติ
echo " - อยู่ในเกณฑ์ปกติ ".$count_female_25." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_29 = mysql_result($query,0,'count_female_29'); // ผู้หญิงอ้วน
echo " - อยู่ในเกณฑ์อ้วน ".$count_female_29." คน<br>"; // ผู้ชายทั้งหมด ...
$count_female_mex = mysql_result($query,0,'count_female_mex'); // ผู้หญิงอ้วนมากๆ
echo " - อยู่ในเกณฑ์อ้วนมากๆ ".$count_female_mex." คน"; // ผู้ชายทั้งหมด ...
}
##################################################################
if($selects=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
$count_1to12_all = mysql_result($query,0,'count_1to12_all'); // อายุ 0-12 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 0 - 12 มีทั้งหมด ".$count_1to12_all." คน "; //
$count_1to12_20 = mysql_result($query,0,'count_1to12_20'); // อายุ 0-12 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_1to12_20. " คน ";
$count_1to12_25 = mysql_result($query,0,'count_1to12_25'); // อายุ 0-12 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_1to12_25. " คน ";
$count_1to12_29 = mysql_result($query,0,'count_1to12_29'); // อายุ 0-12 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_1to12_29. " คน ";
$count_1to12_mex = mysql_result($query,0,'count_1to12_mex'); // อายุ 0-12 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_1to12_mex. " คน <br><br>";
//13 - 19
$count_13to19_all = mysql_result($query,0,'count_13to19_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 13 - 19 มีทั้งหมด ".$count_13to19_all." คน "; //
$count_13to19_20 = mysql_result($query,0,'count_13to19_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_13to19_20. " คน ";
$count_13to19_25 = mysql_result($query,0,'count_13to19_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_13to19_25. " คน ";
$count_13to19_29 = mysql_result($query,0,'count_13to19_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_13to19_29. " คน ";
$count_13to19_mex = mysql_result($query,0,'count_13to19_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_13to19_mex. " คน<br><br>";
//20 - 54
$count_20to54_all = mysql_result($query,0,'count_20to54_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 20 - 54 มีทั้งหมด ".$count_20to54_all." คน "; //
$count_20to54_20 = mysql_result($query,0,'count_20to54_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_20to54_20. " คน ";
$count_20to54_25 = mysql_result($query,0,'count_20to54_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_20to54_25. " คน ";
$count_20to54_29 = mysql_result($query,0,'count_20to54_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_20to54_29. " คน ";
$count_20to54_mex = mysql_result($query,0,'count_20to54_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_20to54_mex. " คน<br><br>";
//55 - 100
$count_55to100_all = mysql_result($query,0,'count_55to100_all'); // อายุ 15-18 ทั้งหมด
echo "คนมีอายุอยู่ระหว่าง 55 - 100 มีทั้งหมด ".$count_55to100_all." คน "; //
$count_55to100_20 = mysql_result($query,0,'count_55to100_20'); // อายุ 15-18 ผอม
echo "อยู่ในเกณฑ์ผอม ".$count_55to100_20. " คน ";
$count_55to100_25 = mysql_result($query,0,'count_55to100_25'); // อายุ 15-18 ปกติ
echo "อยู่ในเกณฑ์ปกติ ".$count_55to100_25. " คน ";
$count_55to100_29 = mysql_result($query,0,'count_55to100_29'); // อายุ 15-18 อ้วน
echo "อยู่ในเกณฑ์อ้วน ".$count_55to100_29. " คน ";
$count_55to100_mex = mysql_result($query,0,'count_55to100_mex'); // อายุ 15-18 อ้วนมากๆ
echo "อยู่ในเกณฑ์อ้วนมากๆ ".$count_55to100_mex. " คน<br>";
}
?>
</div></td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
Date :
2010-08-10 00:13:38
By :
modboyit
มัน error คับพี่ ต้องการให้มันแสดงตามกระทู้คับ ตอนนี้มันแสดงออกมาแบบนี้คับ
มันไม่สวยคับ ต้องทำยังไงคับให้มันแสดงตามลักษณะที่ตั้งกระทู้ไว้คับ
Date :
2010-08-10 00:41:47
By :
เด็กไม่เก่ง
ใส่ table เข้าไปครับ นี่ตัวอย่าง
if($selects=="sex"){
?>
<table>
<tr>
<td>เพศ</td>
<td>เกณฑ์</td>
<td>คน</td>
</tr>
<tr>
<td>ชาย</td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td>หญิง</td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
อีกอันไปทำเองละกัน ตกแต่งสีเองด้วย พิมพ์แค่นี้ก็เมื่อยพอละ หวังว่าจะทำได้นะ
Date :
2010-08-10 05:57:27
By :
PlaKriM
ถ้าใส่tableนี้เข้าไป นตัวแปรของage จะเป็นสีดำ ไม่สามารถทำได้คับ
Date :
2010-08-10 11:10:43
By :
เด็กฝึกหัด
เอาละซิ งามหน้าไหมเนี้ย ไม่ยอมให้เค้าหมด
if($selects=="sex"){
?>
<table>
<tr>
<td>เพศ</td>
<td>เกณฑ์</td>
<td>คน</td>
</tr>
<tr>
<td>ชาย</td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td>หญิง</td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
อะ หายดำยัง
ปล. ผมว่าคุณทำความเข้าใจ หาความรู้เบื่องต้นเกี่ยวกับ html, php อะไรพวกนี้ก่อนดีไหมครับ นี่ผมแนะนำเป็นแนวทางนะครับ ไม่ใช่เขียนให้หมด กะว่าจะให้ไปทำต่อ
ปล.2 กรุณาเลือกเพศด้วยนะครับ เดี๋ยวค่ะเดี๋ยวครับ เพื่ออะไร แมนรับบ่ได้
ประวัติการแก้ไข 2010-08-10 12:22:42
Date :
2010-08-10 12:21:08
By :
PlaKriM
55555 งานเข้าแล้วครับพี่ปลากริม
Date :
2010-08-10 12:23:29
By :
Dragons_first
พี่มันerrorแบบนี้คะ
Parse error: syntax error, unexpected '<' in C:\AppServ\www\hbo\tp.php on line 277
นี้โค๊ดคะ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
?>
<table>
<tr>
<td>เพศ</td>
<td>เกณฑ์</td>
<td>คน</td>
</tr>
<tr>
<td>ชาย</td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td>หญิง</td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
?>
<table width="256">
<tr>
<td>อายุ</td>
<td>เกณฑ์</td>
<td>คน</td>
</tr>
<tr>
<td>1 - 12 </td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td>13 - 19 </td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td>20 - 54 </td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td>55 - 100 </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
?>
</div></td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
<?
</body>
</html>
Date :
2010-08-10 13:07:46
By :
เด็กไม่เก่ง
ขอบคุณ ผมได้เป้นแนวทางในการ join ข้อมูลเลย
Date :
2010-08-10 13:26:00
By :
computer_psu031
ให้ช่วยนะคะ ไม่ได้ให้ก็อป
Date :
2010-08-10 14:48:26
By :
เด็กไม่เก่ง
ที่แรก
Code (PHP)
<?php
}
##################################################################
if($select=="age"){
ที่สอง
Code (PHP)
</table>
<?php
}
?>
</div></td>
ไ่มไ่ด้ปิด if
Date :
2010-08-10 15:23:40
By :
PlaKriM
พี่ ereor
Parse error: syntax error, unexpected '<' in C:\AppServ\www\hbo\tp.php on line 155
แบบนี้
Date :
2010-08-10 16:51:39
By :
เด็กไม่เก่ง
ผิดตรงไหนคะ ช่วยหน่อยคะ
นี้โค๊ดปัจจุบันคะ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
?>
<table width="308" align="center">
<tr>
<td><div align="center"><strong>เพศ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>ชาย</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td><strong>หญิง</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
<FONT size=10>}
</FONT>
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
?>
<table width="374" align="center">
<tr>
<td><div align="center"><strong>อายุ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>1 - 12 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td><strong>13 - 19 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td><strong>20 - 54 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td><strong>55 - 100</strong> </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
<FONT size=10>}</FONT>
?>
</div></td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
Date :
2010-08-10 23:20:39
By :
เด็กฝึกหัด
Code (PHP)
<?php
<FONT size=10>}
</FONT>
?> <<<,///เพิ่มเข้าไปครับ บรรทัดที่ 157
ประวัติการแก้ไข 2010-08-11 10:16:14
Date :
2010-08-11 10:14:19
By :
pob_suwan
ใส่แล้ว ยังเหมือนเดิม
Parse error: syntax error, unexpected '<' in C:\AppServ\www\hbo\tp.php on line 155
Date :
2010-08-11 10:19:33
By :
เด็กฝึกหัด
ผิดตรงไหนคะ ช่วยด้วยยยยยยยยยยยยยยยยยยยยยย
Date :
2010-08-11 11:31:39
By :
เด็กฝึกหัด
<FONT size=10>}</FONT>
หมายถึง } อะนะ
Date :
2010-08-11 11:47:41
By :
PlaKriM
เป็นแบบนี้อีกแล้ว
Parse error: syntax error, unexpected '<' in C:\AppServ\www\hbo\tp.php on line 275
Date :
2010-08-11 13:13:53
By :
เด็กฝึกหัด
ผิดตรงไหนอีกแล้วคะ ช่วยด้วยยยยยยยยยยยยย
Date :
2010-08-11 13:48:29
By :
เด็กฝึกหัด
เอาโค๊ดมาดูครับ แล้วอย่าลืมครอบด้วย code php ด้วย
Parse error: syntax error, unexpected '<' in C:\AppServ\www\hbo\tp.php on line 275
บอกแบบนี้ใครจะตรัสรู้ละท่าน
Date :
2010-08-11 13:49:03
By :
PlaKriM
นี้โค๊ดคะ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
?>
<table width="308" align="center">
<tr>
<td><div align="center"><strong>เพศ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>ชาย</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td><strong>หญิง</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
}
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
?>
<table width="374" align="center">
<tr>
<td><div align="center"><strong>อายุ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>1 - 12 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td><strong>13 - 19 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td><strong>20 - 54 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td><strong>55 - 100</strong> </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
}
</td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
Date :
2010-08-11 14:07:20
By :
เด็กไม่เก่ง
กรรม บอกให้ครอบด้วย code php หน่อย แล้วผมจะรู้ไหมเนี้ย 275 มันอยู่บรรทัดไหน
Date :
2010-08-11 14:18:14
By :
PlaKriM
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
?>
<table width="308" align="center">
<tr>
<td><div align="center"><strong>เพศ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>ชาย</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td><strong>หญิง</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
}
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
?>
<table width="374" align="center">
<tr>
<td><div align="center"><strong>อายุ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>1 - 12 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td><strong>13 - 19 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td><strong>20 - 54 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td><strong>55 - 100</strong> </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
}
</td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
ครอบให้แทนเจ้าของกระทู้ *-* ลำบากคนตอบ ถ้าไม่ครอบ php
Date :
2010-08-11 14:24:50
By :
pob_suwan
Code (PHP)
<?php
}
?>
บรรทัดที่ 273 ตัว ?> ไม่ได้ใส่ ครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
?>
<table width="308" align="center">
<tr>
<td><div align="center"><strong>เพศ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>ชาย</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td><strong>หญิง</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
}
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
?>
<table width="374" align="center">
<tr>
<td><div align="center"><strong>อายุ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>1 - 12 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td><strong>13 - 19 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td><strong>20 - 54 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td><strong>55 - 100</strong> </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
}
?>
</td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
อันนี้แก้โค็ดเพิ่มเข้าไปให้แล้ว ครับ
ประวัติการแก้ไข 2010-08-11 14:31:19 2010-08-11 14:33:22
Date :
2010-08-11 14:30:03
By :
pob_suwan
พี่คะ มันไม่แสดงค่าที่คนออกมาคะ เป็นเพราะอะไรหรือคะ
Date :
2010-08-11 15:19:55
By :
เด็กฝึกหัด
Code (PHP)
<tr>
104.<td><strong>ชาย</strong></td>
105.<td>ทั้งหมด</td>
106.<td><?php echo $count_male_all; ?></td> <<<<<<แกส่วนนี้ดูครับ เป็น <?php echo "$count_male_all"; ?>
107.</tr>
ลองแก้แค่ จุด 2 จุดดูก่อน ครับถ้าแสดง ก็ค่อยแก้ ให้หมดดูครับ
Date :
2010-08-11 15:38:03
By :
pob_suwan
ไม่ออกคะ ยังไม่ออกมาคะพี่ๆ
Date :
2010-08-11 16:10:20
By :
เด็กฝึกหัด
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แสดงรายงานสรุปสถิติ</title>
<style type="text/css">
<!--
body {
background-image: url(image/background.gif);
}
-->
</style></head>
<body>
<center>
<form name="form1" method="post" action="">
<p> </p>
<p> </p>
<table width="448" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>ต้องการแสดงสรุปรายงานสถิติ : </strong></td>
<td><select name="select">
<option value="0" selected="selected">โปรดเลือก</option>
<option value="sex">รายงานสถิติตามเพศ</option>
<option value="age">รายงานสถิติตามอายุ</option>
</select>
<input type="submit" name="button" id="button" value="ตกลง" /></td>
</tr>
</table>
</form>
</center>
<table width="607" height="119" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><p align="center">
<?
$select=$_POST[select];
?>
</p>
<div align="left">
<?
$host="localhost";
$user="root";
$pass="123";
$dbname = "cal";
$connect=mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SELECT*FROM(
SELECT
(select count(*) from bmi_db where sex = 'male') as count_male_all,
(select count(*) from bmi_db where sex = 'male' and BMI <20 ) as count_male_20,
(select count(*) from bmi_db where sex = 'male' and BMI >=20 and BMI <25 ) as count_male_25,
(select count(*) from bmi_db where sex = 'male' and BMI >=25 and BMI <29 ) as count_male_29,
(select count(*) from bmi_db where sex = 'male' and BMI >=29 ) as count_male_mex,
(select count(*) from bmi_db where sex = 'female') as count_female_all,
(select count(*) from bmi_db where sex = 'female' and BMI <20 ) as count_female_20,
(select count(*) from bmi_db where sex = 'female' and BMI >=20 and BMI <25 ) as count_female_25,
(select count(*) from bmi_db where sex = 'female' and BMI >=25 and BMI <29 ) as count_female_29,
(select count(*) from bmi_db where sex = 'female' and BMI >=29 ) as count_female_mex,
(select count(*) from bmi_db where age>=1 and age<=12) as count_1to12_all,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI < 20) as count_1to12_20,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=20 and BMI <25) as count_1to12_25,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=25 and BMI <29) as count_1to12_29,
(select count(*) from bmi_db where age>=1 and age<=12 and BMI >=29) as count_1to12_mex,
(select count(*) from bmi_db where age>=13 and age<=19) as count_13to19_all,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI < 20) as count_13to19_20,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=20 and BMI <25) as count_13to19_25,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=25 and BMI <29) as count_13to19_29,
(select count(*) from bmi_db where age>=13 and age<=19 and BMI >=29) as count_13to19_mex,
(select count(*) from bmi_db where age>=20 and age<=54) as count_20to54_all,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI < 20) as count_20to54_20,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=20 and BMI <25) as count_20to54_25,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=25 and BMI <29) as count_20to54_29,
(select count(*) from bmi_db where age>=20 and age<=54 and BMI >=29) as count_20to54_mex,
(select count(*) from bmi_db where age>=55 and age<=100) as count_55to100_all,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI < 20) as count_55to100_20,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=20 and BMI <25) as count_55to100_25,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=25 and BMI <29) as count_55to100_29,
(select count(*) from bmi_db where age>=55 and age<=100 and BMI >=29) as count_55to100_mex
FROM
bmi_db LIMIT 0,1
)a";
echo" <br>";
$query = mysql_query($sql);
if($select=="sex"){
//echo"เลือก รายงานสถิติตามเพศ <br>";//
$count_male_all = mysql_result($query,0,'count_male_all'); // ผู้ชายทั้งหมด
$count_male_20 = mysql_result($query,0,'count_male_20'); // ผู้ชายผอม
$count_male_25 = mysql_result($query,0,'count_male_25'); // ผู้ชายปกติ
$count_male_29 = mysql_result($query,0,'count_male_29'); // ผู้ชายอ้วน
$count_male_mex = mysql_result($query,0,'count_male_mex'); // ผู้ชายอ้วนมากๆ
$count_female_all = mysql_result($query,0,'count_female_all'); // ผู้หญิงทั้งหมด
$count_female_20 = mysql_result($query,0,'count_female_20'); // ผู้หญิงผอม
$count_female_25 = mysql_result($query,0,'count_female_25'); // ผู้หญิงปกติ
$count_female_29 = mysql_result($query,0,'count_female_29'); // ผู้หญิงอ้วน
$count_female_mex = mysql_result($query,0,'count_female_mex'); // ผู้หญิงอ้วนมากๆ
?>
<table width="308" align="center">
<tr>
<td><div align="center"><strong>เพศ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>ชาย</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_male_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_male_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_male_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_male_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_male_mex; ?></td>
</tr>
<tr>
<td><strong>หญิง</strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_female_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_female_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_female_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_female_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_female_mex; ?></td>
</tr>
</table>
<?php
}
##################################################################
if($select=="age"){
//echo"เลือก รายงานสถิติตามอายุ <br>";/
//1-12
$count_1to12_all = mysql_result($query,0,'count_1to12_all'); // อายุ 0-12 ทั้งหมด
$count_1to12_20 = mysql_result($query,0,'count_1to12_20'); // อายุ 0-12 ผอม
$count_1to12_25 = mysql_result($query,0,'count_1to12_25'); // อายุ 0-12 ปกติ
$count_1to12_29 = mysql_result($query,0,'count_1to12_29'); // อายุ 0-12 อ้วน
$count_1to12_mex = mysql_result($query,0,'count_1to12_mex'); // อายุ 0-12 อ้วนมากๆ
//13 - 19
$count_13to19_all = mysql_result($query,0,'count_13to19_all'); // อายุ 15-18 ทั้งหมด
$count_13to19_20 = mysql_result($query,0,'count_13to19_20'); // อายุ 15-18 ผอม
$count_13to19_25 = mysql_result($query,0,'count_13to19_25'); // อายุ 15-18 ปกติ
$count_13to19_29 = mysql_result($query,0,'count_13to19_29'); // อายุ 15-18 อ้วน
$count_13to19_mex = mysql_result($query,0,'count_13to19_mex'); // อายุ 15-18 อ้วนมากๆ
//20 - 54
$count_20to54_all = mysql_result($query,0,'count_20to54_all'); // อายุ 15-18 ทั้งหมด
$count_20to54_20 = mysql_result($query,0,'count_20to54_20'); // อายุ 15-18 ผอม
$count_20to54_25 = mysql_result($query,0,'count_20to54_25'); // อายุ 15-18 ปกติ
$count_20to54_29 = mysql_result($query,0,'count_20to54_29'); // อายุ 15-18 อ้วน
$count_20to54_mex = mysql_result($query,0,'count_20to54_mex'); // อายุ 15-18 อ้วนมากๆ
//55 - 100
$count_55to100_all = mysql_result($query,0,'count_55to100_all'); // อายุ 15-18 ทั้งหมด
$count_55to100_20 = mysql_result($query,0,'count_55to100_20'); // อายุ 15-18 ผอม
$count_55to100_25 = mysql_result($query,0,'count_55to100_25'); // อายุ 15-18 ปกติ
$count_55to100_29 = mysql_result($query,0,'count_55to100_29'); // อายุ 15-18 อ้วน
$count_55to100_mex = mysql_result($query,0,'count_55to100_mex'); // อายุ 15-18 อ้วนมากๆ
?>
<table width="374" align="center">
<tr>
<td><div align="center"><strong>อายุ</strong></div></td>
<td><div align="center"><strong>เกณฑ์</strong></div></td>
<td><div align="center"><strong>คน</strong></div></td>
</tr>
<tr>
<td><strong>1 - 12 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_1to12_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_1to12_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_1to12_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_1to12_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_1to12_mex; ?></td>
</tr>
<tr>
<td><strong>13 - 19 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_13to19_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_13to19_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_13to19_25;?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_13to19_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_13to19_mex; ?></td>
</tr>
<tr>
<td><strong>20 - 54 </strong></td>
<td>ทั้งหมด</td>
<td><?php echo $count_20to54_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_20to54_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_20to54_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_20to54_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_20to54_mex; ?></td>
</tr>
<tr>
<td><strong>55 - 100</strong> </td>
<td>ทั้งหมด</td>
<td><?php echo $count_55to100_all; ?></td>
</tr>
<tr>
<td> </td>
<td>ผอม</td>
<td><?php echo $count_55to100_20; ?></td>
</tr>
<tr>
<td> </td>
<td>ปกติ</td>
<td><?php echo $count_55to100_25; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วน</td>
<td><?php echo $count_55to100_29; ?></td>
</tr>
<tr>
<td> </td>
<td>อ้วนมาก</td>
<td><?php echo $count_55to100_mex; ?></td>
</tr>
</table>
<?php
}
?>
</td>
</tr>
</table>
<p> </p>
<p align="center"><a href="adin.php"><strong>กลับ</strong></a></p>
</body>
</html>
เหมือนลืมส่วนนั้นไปนะ ลองดูครับตามด้านบน
Date :
2010-08-11 16:24:10
By :
pob_suwan
ได้แล้วคะ ขอบคุณมากๆคะๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆ ขอบคุณจริงๆๆๆๆๆ
Date :
2010-08-11 16:29:59
By :
เด็กฝึกหัด
ดีใจด้วยครับ
Date :
2010-08-11 16:39:04
By :
pob_suwan
Load balance : Server 04