<?php include 'lab3_1_function.php'; prepareStatement(); $status=doOperatorStatement() ; global $scores,$ids; $ids=$_POST['id']; $scores=$_POST['score']; ?> <form name="form1" method="post" action="lab3_1.php"> <table border="1"> <tr> <td><input type="text" name="id[]" value="<?php echo $ids[$i]?>"></td> <td><input type="text" name="score[]" maxlength="2" value="<?php echo $scores[$i]?>"></td> </tr> <?php ?> <tr> <td colspan=2 align="center"><input type="submit" name="submit" value="คำนวณ"><input type="reset" value="ล้างค่า"></td> </tr> </table> </form> <?php echo showResult($status); ?> </body> </html> <td>ชื่อ</td> <td>คะแนน</td> </tr> <?php for($i=0;$i<10;$i++) ?>
<? function prepareStatement(){ ; } function doOperatorStatement(){ global $maximum,$minimum,$average; $maximum = getMaximum() ; $minimum = getMinimum(); $average = getAverage(); return true; } function showResult($value){ global $maximum,$minimum,$average; if($value ){ $tmp ='<table>'; $tmp.="<tr><td>ค่าสูงสุด</td><td>$maximum</td></tr>"; $tmp.="<tr><td>ค่าต่ำสุด</td><td>$minimum</td></tr>"; $tmp.="<tr><td>ค่าเฉลี่ย</td><td>$average</td></tr>"; $tmp.='</table>'; return $tmp; } } function getMaximum(){ global $scores; $tmp=''; if(isset($scores)){ return; foreach( $scores as $score){ if(true ) $tmp = $score; } return $tmp; } } function getMinimum(){ global $scores; if(true ){ foreach($scores as $scores ){ if($scores= ''&&($tmp='' ||$scores<tmp )) $tmp = $score; } if( $tmp=$scores) return ''; else $tmp=''; } } function getAverage(){ global $scores; $round=0; if(isset($scores)) { foreach($scores as $score){ if($score!=''){ $round++; $tmp += $score; } } if($round==0) return null; return $tmp/$round; } } function requestStatement(){ global $scores,$ids; global $scores,$ids; $ids=$_POST['id']; $scores=$_POST['score']; } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง