|
 |
|
ขอคำแนะนำหน่อยคะ ทำไมไม่แสดงออกมาคะ มันขึ้นมาแบบนี้คะ ไม่รู้ว่าผิดตรงไหน ไม่แสดงค่าของbmr ออกมาคะ |
|
 |
|
|
 |
 |
|
มันขึ้นมาแบบนี้คะ ไม่รู้ว่าผิดตรงไหน ไม่แสดงค่าของbmr ออกมาคะ ช่วยแนะนำหน่อยคะ ว่าผิดตรงไหน
...ค่าปริมาณพลังงานที่ร่างกายต้องการต่อวันของคุณ คือ ..
นี้โค๊ดคะ
<!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>Untitled Document</title>
</head>
<body>
<?
$sex=$_POST[sex];
$age=$_POST[age];
if ($age==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$height=$_POST[height];
if( $height==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$weight=$_POST[weight];
if ($weight==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$job=$_POST[job];
if($sex=="" or $age=="" or $height=="" or $weight=="" or $job=="")
{
echo " กรุณาป้อนข้อมูลให้ครบ";
exit();
}
include "connect2.php";
$sql="select * from bmr_db where no='$no' ";
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num > 0){
echo "ลำดับที่";
exit();
}
$sql = "insert into bmr_db(date,sex,age,height,weight,job)
value('$date','$sex', '$age', '$height','$weight','job')";
$result = mysql_db_query($dbname,$sql);
if($result){
//echo " บันทึกข้อมูลเรียบร้อย";//
}else{
// echo "ไม่สามารถบันทึกข้อมูลได้<br>";//
}
mysql_close();
echo "ค่าปริมาณพลังงานที่ร่างกายต้องการต่อวันของคุณ คือ " . $BMR . " ";
if(sex=="male")
{
//66 + (13.7 x น้ำหนักตัวเป็น กก.) + (5 x ส่วนสูงเป็น ซม.) – (6.8 x อายุ)//
$result = 66 + (13.7*$weight) + (5*$height) - (6.8*$age);
$BMR = $result * $job;
}
else if (sex=="female")
{
// 665 + (9.6 x น้ำหนักตัวเป็น กก.) + (1.8 x ส่วนสูงเป็น ซม.) – (4.7 x อายุ)//
$result = 655 + (9.6*$weight) +(1.8* $height) - (4.7*$age);
$BMR =$result * $job;
}
?>
</body>
</html>
ช่วยแนะนำหน่อยค่ะ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-07-07 12:54:00 |
By :
นก |
View :
834 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
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>Untitled Document</title>
</head>
<body>
<?
$sex=$_POST[sex];
$age=$_POST[age];
if ($age==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$height=$_POST[height];
if( $height==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$weight=$_POST[weight];
if ($weight==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$job=$_POST[job];
if($sex=="" or $age=="" or $height=="" or $weight=="" or $job=="")
{
echo " กรุณาป้อนข้อมูลให้ครบ";
exit();
}
include "connect2.php";
$sql="select * from bmr_db where no='$no' ";
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num > 0){
echo "ลำดับที่";
exit();
}
$sql = "insert into bmr_db(date,sex,age,height,weight,job)
value('$date','$sex', '$age', '$height','$weight','job')";
$result = mysql_db_query($dbname,$sql);
if($result){
//echo " บันทึกข้อมูลเรียบร้อย";//
}else{
// echo "ไม่สามารถบันทึกข้อมูลได้<br>";//
}
mysql_close();
echo "ค่าปริมาณพลังงานที่ร่างกายต้องการต่อวันของคุณ คือ " . $BMR . " ";
if(sex=="male")
{
//66 + (13.7 x น้ำหนักตัวเป็น กก.) + (5 x ส่วนสูงเป็น ซม.) – (6.8 x อายุ)//
$result = 66 + (13.7*$weight) + (5*$height) - (6.8*$age);
$BMR = $result * $job;
}
else if (sex=="female")
{
// 665 + (9.6 x น้ำหนักตัวเป็น กก.) + (1.8 x ส่วนสูงเป็น ซม.) – (4.7 x อายุ)//
$result = 655 + (9.6*$weight) +(1.8* $height) - (4.7*$age);
$BMR =$result * $job;
}
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-07-07 13:00:05 |
By :
oxygenyoyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
php อ่านข้อมูลจากบนลงไปล่างให้คุณเอาบรรทัดที่จะแสดงผลไปไว้หลังจากคำนวนครับ
Code (PHP)
if(sex=="male")
{
//66 + (13.7 x น้ำหนักตัวเป็น กก.) + (5 x ส่วนสูงเป็น ซม.) – (6.8 x อายุ)//
$result = 66 + (13.7*$weight) + (5*$height) - (6.8*$age);
$BMR = $result * $job;
}
else if (sex=="female")
{
// 665 + (9.6 x น้ำหนักตัวเป็น กก.) + (1.8 x ส่วนสูงเป็น ซม.) – (4.7 x อายุ)//
$result = 655 + (9.6*$weight) +(1.8* $height) - (4.7*$age);
$BMR =$result * $job;
}
echo "ค่าปริมาณพลังงานที่ร่างกายต้องการต่อวันของคุณ คือ " . $BMR . " ";
|
 |
 |
 |
 |
Date :
2010-07-07 13:02:56 |
By :
oxygenyoyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าใช้codeนี้อะค่ะได้ไหม
Code (PHP)
<?
require("connect2.php");
$sex=$_POST[sex];
$age=$_POST[age];
$job=$_POST[job];
if ($age==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$height=$_POST[height];
if( $height==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
$weight=$_POST[weight];
if ($weight==0){
echo " กรุณาป้อนให้มากกว่า0 ตั้งแต่ 1 ขึ้นไป เนื่องจากระบบไม่สามารถจะคำนวณได้ ขอบคุณคะ";
exit();}
if($sex=="" or $age=="" or $height=="" or $weight=="" or $job=="")
{
echo " กรุณาป้อนข้อมูลให้ครบ";
exit();
}
$result =mysql_query("select * from bmr_db where no='$no'");
//$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num > 0){
echo "ลำดับที่";
exit();
}
$result = mysql_query("insert into bmr_db(date,sex,age,height,weight,job)value('$date','$sex', '$age','$height','$weight','job')");
//$result = mysql_db_query($dbname,$sql);
if($result){
echo " บันทึกข้อมูลเรียบร้อย";
}else{
echo "ไม่สามารถบันทึกข้อมูลได้<br>";
}
mysql_close();
if($sex=="male")
{
//66 + (13.7 x น้ำหนักตัวเป็น กก.) + (5 x ส่วนสูงเป็น ซม.) – (6.8 x อายุ)//
$result = 66 + (13.7*$weight) + (5*$height) - (6.8*$age);
$BMR = $result * $job;
}
else if ($sex=="female")
{
// 665 + (9.6 x น้ำหนักตัวเป็น กก.) + (1.8 x ส่วนสูงเป็น ซม.) – (4.7 x อายุ)//
$result = 655 + (9.6*$weight) +(1.8* $height) - (4.7*$age);
$BMR =$result * $job;
}
echo "ค่าปริมาณพลังงานที่ร่างกายต้องการต่อวันของคุณ คือ " . $BMR . " ";
?>
|
 |
 |
 |
 |
Date :
2010-07-07 13:06:51 |
By :
LuckyStar |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัดที่47 กับ 55 sex คุณลืม$ด้วยป่าว
แสดงข้อมูลต้องอยู่ด้านล่างนะค่ะ
|
 |
 |
 |
 |
Date :
2010-07-07 13:08:20 |
By :
LuckyStar |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆๆคะ แสดงออกมาแล้ว ขอบคุณจริงๆคะ
|
 |
 |
 |
 |
Date :
2010-07-07 13:17:43 |
By :
นก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอถามพี่อีกนิดหนึ่งนะคะ ทำไมเวลาดูในฐานข้อมูล มันถึง แสดงออกแบบนี้คะในช่อง job

ทั้งๆในแบบฟอร์ม มันมีในเลือก แบบนี้คะ

แต่พอดูในฐานข้อมูล มันก็ออกเป็นแบบนั้นคะ
|
 |
 |
 |
 |
Date :
2010-07-07 13:44:05 |
By :
นก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$result = mysql_query("insert into bmr_db(date,sex,age,height,weight,job)value('$date','$sex', '$age','$height','$weight','$job')");
คุณลืมใส่ $ หน้า job อ่าครับ
ลองดูเน้อ
|
 |
 |
 |
 |
Date :
2010-07-07 14:18:57 |
By :
dekcomnvc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากคะ ได้แล้วคะ ขอบคุณจริงๆคะ
|
 |
 |
 |
 |
Date :
2010-07-07 17:01:28 |
By :
นก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าต้องเก็บค่า bmrที่คำนวณได้ จะต้องเพิ่มคำสั่ง หรือตัวแปรอะไรเข้าไปที่ไหน บ้างหรือคะ ถ้าในฐานข้อมูลดิฉันได้เพิ่มฟิวส์ไปแล้วคะ ชื่อฟิวส์ว่า bmr คะ ขอคำแนะนำด้วยคะ
|
 |
 |
 |
 |
Date :
2010-07-07 17:19:31 |
By :
นก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|