|
 |
|
ช่วยด้วยครับ เกี่ยวกับการแสดงค่าคำนวณบน server คือตอนผมลองใน localhost ผลคำนวณแสดงเป็นปกตินะครับ |
|
 |
|
|
 |
 |
|
include "register_global.php";
ขอดูโค๊ดนี้ครับ ว่ามันเขียนยังไง
การคำนวนปกติ ไม่เกี่ยวนะครับ แต่ที่มันจะเกี่ยวคือโค๊ดเรา ว่ามันติดต่อฐานข้อมูลได้หรือเปล่า เพราะดูแล้ว ข้อมูลมัน ดึงไม่มาเลยสักอันนะนั่น
|
 |
 |
 |
 |
Date :
2009-09-20 22:26:52 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่คือ Code หน้าที่ใช้คำนวณครับ คือจะรับค่าจาก checkbox จากหน้าก่อนหน้านี้มา เช่น ถ้า เลือก chckbox 1 ก็จะให้ checkbox 1 มีค่าเป็น 1 ครับ ทั้งหมดประมาณ 160 checkbox ครับ
Code (PHP)
<?php
include "register_global.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>โปรแกรมวินิจฉัยโรคสุนัข</title>
<meta http-equiv=Content-Type content="text/html; charset=tis-620">
<style type="text/css">
<!--
body {
background-image: url(image/wall3.jpg);
}
a:link {
color: #0000FF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #FF0000;
}
.style1 {color: #0066FF}
-->
</style></head>
<body>
<div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="900" height="150">
<param name="movie" value="banner.swf">
<param name="quality" value="high">
<embed src="banner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="150"></embed>
</object>
<p></p><table width="900" height="400" border="1" bordercolor="#0000FF">
<tr>
<td align="center" valign="top" background="image/BG_main.jpg"><div align="left">
<p><a href="index.php"><img src="image/home.png" width="80" height="80" border="0"></a></p>
<p align="center">
<?php
function show($calshow)
{
if ($calshow%5 == 0)
{
printf("%.0f",$calshow);//แสดงค่าเป็นทศนิยม 0 ตำแหน่ง
}
else
{
printf("%.2f",$calshow); //แสดงค่าเป็นทศนิยม 2 ตำแหน่ง
}
}
include ("connect.php");
$newtable = "CREATE TABLE `conclude` (
`id` INT( 2 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 60 ) CHARACTER SET tis620 COLLATE tis620_thai_ci NOT NULL ,
`cal` FLOAT( 4 ) NOT NULL
) ENGINE = MYISAM ;";
$result = mysql_query($newtable) or die(mysql_error());
?>
</p>
<h2 align="center" class="style1">สรุปผลการวินิจฉัย</h2>
<form name="form1" method="post" action="show_data.php">
<center>
<?php
$sql = "Select * from alldisease order by id";
$query = mysql_query($sql);
?>
<center>
<table width="550" border="0" bordercolor="#000000">
<tr>
<td width="250"><div align="left">โรคที่มีโอกาสเกิด</div></td>
<td width="150"><div align="center">โอกาสเกิดร้อยละ (%)</div></td>
<td width="150"><div align="center">Link</div></td>
</tr>
</table>
</center>
<?php
while ($data = mysql_fetch_array($query))
{
$thname = $data['name'];
//echo $thname;
$tbname = $data['enname'];
//echo $tbname;
$sumcheckbox = 0;
$strname = "select * from $tbname order by id";
$queryname = mysql_query($strname);
$numname = mysql_num_rows($queryname);
while ($dataname = mysql_fetch_array($queryname))
{
$j = $dataname['id'];
${checkbox.$j};
$sumcheckbox = $sumcheckbox + ${checkbox.$j};
}
$total = (100*$sumcheckbox)/$numname;
if ($total==0)
{
$cal = 0;
//echo "<font color = '#FFFF00'>ปลอดภัยจากโรคนี้</font>";
}
else
{
$cal = $total;
}
$sql = "insert into conclude values('','$thname','$cal')";
mysql_query($sql) or die ("Insert ERROR!!!");
}
$sql2 = "Select * from conclude order by cal desc";
$query2 = mysql_query($sql2);
while ($data2 = mysql_fetch_array($query2))
{
$checkcal = $data2['cal'];
//echo $checkcal;
if ($checkcal == 0)
{
//ถ้าค่าวินิจฉัยเป็นศูนย์จะไม่มีอะไรแสดงออกมา
}
else
{
?>
<table width="550" border="0" bordercolor="#000000">
<tr>
<td width="250"><div align="left">
<?=$data2['name']?>
</div></td>
<td width="150"><div align="center">
<?php
$calshow = $data2['cal'];
show($calshow);//เรียกใช้ Function show($calshow)
?>
</div></td>
<td width="150"><div align="center">
<a href='show_data.php?name=<? echo $data2["name"]; ?>' target='_blank'>อ่านรายละเอียด</a>
</div></td>
</tr>
</table>
</center>
<div align="center">
<?php
}//ปิด else ที่เช็คค่าวินิจฉัยเป็น 0
}//ปิด while
$deletetable = "DROP TABLE `conclude`";
$result = mysql_query($deletetable) or die(mysql_error());
?>
</div>
</form>
</div></td>
</tr>
</table>
</div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-09-20 23:09:34 |
By :
suzuhara |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถึงคุณ suzuhara
ตอนนี้ผมก็กำลังเขียนโปรแกรมวินิจฉัยโรคปลาอยู่ซึ่งยังไม่เข้าใจในหลายๆอย่างตั่งแต่ การรับค่าไปจนถึงการคำนวณและสรุปผล ถ้าไม่เป็นการรบกวนจนเกินไป ผมขอดู code พวกนี้ได้ไหมครับ
|
 |
 |
 |
 |
Date :
2009-11-19 08:47:19 |
By :
sarangheayo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|