HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux host 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: w230 (1248)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/w230/html/hwnapp/index.php
<?php
require_once('connections/mysqli.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title><?php echo $title; ?></title>
  
  <link rel="icon" type="image/png" href="images/logo1.png"/>
  <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/icons/bootstrap-icons.css">
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Mitr:wght@300&display=swap" rel="stylesheet">
    <style type="text/css">
    body{
      font-family: 'Mitr', sans-serif;
    }
  </style>
</head>
<body class="default">
  <?php include 'includes/navbar.php'; // ดึงโค้ดปุ่มหัวด้านบทสุด ?>
  <?php include 'includes/select_class.php'; // ดึงโค้ดให้เลือกประถม มัธยมศึกษา ?>
  <?php 
  isset( $_GET['floor'] ) ? $floor = $_GET['floor'] : $floor = ""; //รับค่าระดับชั้น
  //echo "floor = {$floor}";?>
  <?php /*ตรวจสอบเลือกระดับชั้นประถม/มัธยม กรณีไม่เลือกให้โปรแกรมแจ้งเลือกระดับชั้นก่อนเสมอ*/ ?>
  <?php /* คำสั่งโปรแกรมประถมศึกษา*/
      if($floor=='P') // P ประถม
      {
        ?>
        <div class="container-fluid">
        <div class="row justify-content-md-center">
        <div class="col-md-8 py-4">
        <form class="row" method="POST">
          <div class="col col-lg-2">
            <select class="form-select" name="select" required>
              <option value="" selected disabled> -- เลือกข้อมูล -- </option>
              <option value="student_code" <?php if (isset($_POST['select'])) {if ($_POST['select'] == 'student_code') {echo 'selected';}} ?>>รหัสนักศึกษา</option>
              <option value="student_name" <?php if (isset($_POST['select'])) {if ($_POST['select'] == 'student_name') {echo 'selected';}} ?>>ชื่อ</option>
            </select>
          </div>
          
          <div class="col">
            <input type="text" class="form-control" name="value" value="<?php if (isset($_POST['value'])) {echo $_POST['value'];} ?>" required/>
          </div>
          <div class="col-md-auto">
            <button type="submit" name="submit" class="btn btn-success">ค้นหา</button>
          </div>
        </form>
          <?php
            if (isset($_POST['submit'])) 
              {
                $num = 1;
                $sql = "SELECT * FROM tb_gstudent66 INNER JOIN tb_class ON (tb_gstudent66.student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
                $query = mysqli_query($Connection,$sql);
                $check_data = mysqli_num_rows($query);
                if ($check_data == 0) 
                  {
                    echo '<p class="text-center py-4"><span class="badge bg-danger" style="font-size: 20px;">ไม่พบข้อมูล</span></p>';
                  }
                  else
                  {
          ?>
            <table class="table table-bordered mt-4">
              <thead class="table-secondary">
                <tr>
                  <!--<th scope="col" class="text-center">ลำดับที่</th>-->
                  <th scope="col" class="text-center">รหัสนักนักเรียน</th>
                  <th scope="col" class="text-center">ชื่อ - นามสกุล</th>
                  <th scope="col" class="text-center">ระดับชั้น</th>
                  <!--<th scope="col" class="text-center">ดูผลการเรียน</th>-->
                </tr>
              </thead>
              <tbody>
                <?php
                  while ($result = mysqli_fetch_array($query)) 
                    {
                    ?>
                  <tr>
                    <!--<td class="text-center"><?php echo $num++; ?></td>-->
                    <td class="text-center"><?php echo $result['student_code']; ?></td>
                    <td><?php echo $result['student_prefix'].$result['student_name']; ?></td>
                    <td><?php echo $result['Name_Class']; ?></td>
                    <!--<td class="text-center"><?php //echo "คลิก";?></td>-->
                  </tr>
                  <?php
                    }
                  ?>
              </tbody>
            </table>
                <?php
                  $sql = "SELECT * FROM tb_gstudent66 INNER JOIN tb_class ON (tb_gstudent66.student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
                  $query = mysqli_query($Connection,$sql);
                  $check_data = mysqli_num_rows($query);
                  while ($result = mysqli_fetch_array($query)) 
                    {
                ?>

            <table class="table table-bordered mt-4">
              <thead class="table-secondary">
                <tr>
                  <td colspan="2" class="text-center bg-info">แสดงผลการเรียน <?php echo $result['student_prefix'].$result['student_name'];?></td>
              </thead>
              <tbody>
                  <tr>
                  <td class="text-center bg-warning fw-bold" width="70%"><?php echo "วิชา"; ?></td>
                  <td class="text-center bg-warning fw-bold" width="30%"><?php echo "เกรด"; ?></td>
                  </tr>
                  <thead class="table-secondary">
                  <tr>
                  <td colspan="3" class="bg-light text-center">รายวิชาพื้นฐาน</td></tr>
                  </thead>
                  <tr>
                  <td><?php echo "ภาษาไทย"; ?></td>
                  <td class="text-center">
                    <?php echo $result['subject_thai']; /*กำหนดตัวแปร thai (เกรดวิชาภาษาไทย)*/ 
                    /*กำหนดตัวแปร Credit(เก็บค่าหน่วยกิต) กำหนดตัวแปร thai เก็บเกรดที่ได้*/
                      if($result['subject_thai']=="") 
                        { $Credit_thai=0; /*echo"ไม่มีเกรด";*/}
                      else 
                        {  //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 200 ชม. ป.4-6 160 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_thai=5; $thai=$result['subject_thai']*$Credit_thai;//echo "&nbsp;". $thai."  ".$Credit_thai ;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_thai=4; $thai=$result['subject_thai']*$Credit_thai;//echo "&nbsp;". $thai."  ".$Credit_thai ;
                          }
                        }
                    ?>
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "คณิตศาสตร์"; ?></td>
                  <td class="text-center">
                    <?php echo $result['subject_math']; 
                      if($result['subject_math']=="")
                        { $Credit_math=0;}
                      else
                        { 
                          //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 200 ชม. ป.4-6 160 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_math=5; $math=$result['subject_math']*$Credit_math;//echo "&nbsp;". $math."  ".$Credit_math ;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_math=4; $math=$result['subject_math']*$Credit_math;//echo "&nbsp;". $math."  ".$Credit_math ;
                          }
                        }
                    ?>
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "วิทยาศาสตร์";?></td>
                  <td class="text-center">
                    <?php echo $result['subject_Science'];
                      if($result['subject_Science']=="")
                        { $Credit_Science=0;}
                      else
                        { 
                          //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 80 ชม. ป.4-6 120 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_Science=2; $science=$result['subject_Science']*$Credit_Science;//echo "&nbsp;". $science."  ".$Credit_Science ;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_Science=3; $science=$result['subject_Science']*$Credit_Science;//echo "&nbsp;". $science."  ".$Credit_Science ;
                          }
                        }
                       
                    ?>
                </td>
                  </tr>
                  <tr>
                  <td><?php echo "สังคมศึกษา ศาสนาและวัฒนธรรม";?></td>
                  <td class="text-center">
                    <?php echo $result['subject_social'];
                      if($result['subject_social']=="")
                        { $Credit_social=0;}
                      else
                        { 
                          $Credit_social=2;$social=$result['subject_social']*$Credit_social;//echo "&nbsp;". $social."  ".$Credit_social ;
                        }
                    
                    ?>                    
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "ประวัติศาสตร์"; ?></td>
                  <td class="text-center">
                    <?php echo $result['subject_history'];
                      if($result['subject_history']=="")
                        { $Credit_history=0;}
                      else
                        { $Credit_history=1;$history=$result['subject_history']*$Credit_history;//echo "&nbsp;". $history."  ".$Credit_history ;
                        }
                    ?>
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "ศิลปะ"; ?></td>
                  <td class="text-center">
                    <?php echo $result['subject_art'];
                      if($result['subject_art']=="")
                      { $Credit_art=0;}
                    else
                      { 
                        //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 40 ชม. ป.4-6 80 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_art=1; $art=$result['subject_art']*$Credit_art;//echo "&nbsp;". $art."  ".$Credit_art ;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_art=2; $art=$result['subject_art']*$Credit_art;//echo "&nbsp;". $art."  ".$Credit_art ;
                          }
                      }
                    ?>
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "สุขศึกษาและพลศึกษา";?></td>
                  <td class="text-center">
                    <?php echo $result['subject_health'];
                      if($result['subject_health']=="")
                        { $Credit_health=0;}
                      else
                        { 
                          //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 40 ชม. ป.4-6 80 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_health=1; $health=$result['subject_health']*$Credit_health;//echo "&nbsp;". $health."  ".$Credit_health ;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_health=2; $health=$result['subject_health']*$Credit_health;//echo "&nbsp;". $health."  ".$Credit_health ;
                          }
                        }
                     
                    ?>
                  </td>
                  </tr>
                  <tr>
                  <td><?php echo "การงานอาชีพ";?></td>
                  <td class="text-center">
                    <?php echo $result['subject_job'];
                      if($result['subject_job']=="")
                        { $Credit_job=0;}
                      else
                        { $Credit_job=1;$job=$result['subject_job']*$Credit_job;//echo "&nbsp;". $job."  ".$Credit_job;
                        }                     
                    ?>                      
                    </td>
                  </tr>
                  <tr>
                  <td><?php echo "ภาษาอังกฤษ";?></td>
                  <td class="text-center">
                    <?php echo $result['subject_eng'];
                      if($result['subject_eng']=="")
                        { $Credit_eng=0;}
                      else
                        { 
                          //echo $result['student_id_class'];
                          /* ตรวจสอบระดับชั้น หน่วยกิตไม่เหมือนกัน ป.1-3 120 ชม. ป.4-6 80 ชม.*/
                          if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5 ) /* ป.1-3 */
                          {
                            $Credit_eng=3; $eng=$result['subject_eng']*$Credit_eng;//echo "&nbsp;". $eng."  ".$Credit_eng;
                          }
                          if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8 ) /* ป.4-6 */
                          {
                            $Credit_eng=2; $eng=$result['subject_eng']*$Credit_eng;//echo "&nbsp;". $eng."  ".$Credit_eng;
                          }
                        }                     
                    ?>
                  </td>
                  </tr>
                  <thead class="table-secondary">
                  <tr>
                  <td colspan="3" class="bg-light text-center">รายวิชาเพิ่มเติม</td></tr>
                  </thead>
                  <!--แสดงรายวิชาเพิ่มเติม ภาษาอังกฤษ(เพิ่มเติม) ตรวจสอบ ป.1-3 80 ชม. -->
                  <?php //echo $result['student_id_class'];
                  if($result['student_id_class']==3 or $result['student_id_class']==4 or $result['student_id_class']==5)
                      { //echo"ระดับชั้น ป.1-3";
                        echo"<tr>";
                        echo "<td>";
                        echo "ภาษาอังกฤษ(เพิ่มเติม)</td>";
                        echo "<td class=text-center>";
                        echo $result['subject_engP'];
                        $Credit_engP=2;
                        $engP=$result['subject_engP']*$Credit_engP;
                        //echo "&nbsp;". $engP."  ".$Credit_engP;
                        echo"</td>";
                        echo"</tr>";
                      }
                      /* ตรวจสอบ ป.4-6 40 ชม.*/
                    elseif ($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8) 
                      {
                        //echo"ระดับชั้น ป.4-6 ";
                        echo"<tr>";
                        echo "<td>";
                        echo "ภาษาอังกฤษ(เพิ่มเติม)</td>";
                        echo "<td class=text-center>";
                        echo $result['subject_engP'];
                        $Credit_engP=1;
                        $engP=$result['subject_engP']*$Credit_engP;
                        //echo "&nbsp;". $engP."  ".$Credit_engP;
                        echo"</td>";
                        echo"</tr>";
                      }
                      else
                      { 
                        $Credit_engP=0;
                        $engP=0;
                      } 
                      ?>                                    
                  <tr>
                  <td><?php echo "หน้าที่พลเมือง(เพิ่มเติม)"; ?></td>
                  <td class="text-center">
                    <?php echo $result['subject_duty'];
                      if($result['subject_duty']=="")
                        { $Credit_dutyP=0;}
                      else
                        { $Credit_dutyP=1;$dutyP=$result['subject_duty']*$Credit_dutyP;//echo "&nbsp;". $dutyP."  ".$Credit_dutyP;
                        }
                    ?>
                  </td>
                  </tr>
                  <!--แสดงรายวิชาเพิ่มเติม คณิตศาสตร์(เพิ่มเติม) ตรวจสอบ ป.4-6 ม.1-3(wait)-->
                  <?php //echo $result['student_id_class'];
                  if($result['student_id_class']==6 or $result['student_id_class']==7 or $result['student_id_class']==8)
                      { //echo"ระดับชั้น ป.4-6";
                        echo"<tr>";
                        echo "<td>";
                        echo "คณิตศาสตร์(เพิ่มเติม)</td>";
                        echo "<td class=text-center>";
                        echo $result['subject_mathP'];
                        $Credit_mathP=1;
                        $mathP=$result['subject_mathP']*$Credit_mathP;
                        //echo "&nbsp;". $mathP."  ".$Credit_mathP;
                        echo"</td>";
                        echo"</tr>";
                      }
                    else
                      { 
                        $Credit_mathP=0;
                        $mathP=0;
                      }
                    ?>
                 
                  <tr>
                  <td class="bg-info text-center fw-bold"><?php echo "เกรดเฉลี่ย"; ?></td>
                  <td class="text-center fw-bold">
                    <?php /*กำหนดตัวแปรเก็บหน่วยกิตทั้งหมด sumCredit*/ 
                    $sumCredit=$Credit_thai+$Credit_math+$Credit_Science+$Credit_social+$Credit_history+$Credit_art+$Credit_health+$Credit_job+$Credit_eng+$Credit_engP+$Credit_dutyP+$Credit_mathP; 
                    /*กำหนดตัวแปรเก็บผลหน่วยกิตที่ได้ (เกรดxหน่วยกิต) sumUnit*/ 
                    $sumUnit=$thai+$math+$science+$social+$history+$art+$health+$job+$eng+$engP+$dutyP+$mathP; /*รวมหน่วยที่ได้*/ echo number_format($sumUnit/$sumCredit, 2, '.', ''); //echo "<br>หน่วยกิตทั้งหมด" .$sumCredit."<br>ผลคูณหน่วยกิตรวม". $sumUnit;?>
                  </td> 
                  </tr>
                  <?php
                }
                ?>
              </tbody>
            </table>
            <?php
          }
        }
        ?>
      </div>
    </div>
  </div>
  <?php
      }     
  ?>

  <?php /*=============คำสั่งระดับมัธยมศึกษา==================*/
  if ($floor=='M') 
      {
        ?>
        <div class="container-fluid">
        <div class="row justify-content-md-center">
        <div class="col-md-8 py-4">
        <form class="row" method="POST">
          <div class="col col-lg-2">
            <select class="form-select" name="select" required>
              <option value="" selected disabled> -- เลือกข้อมูล -- </option>
              <option value="student_code" <?php if (isset($_POST['select'])) {if ($_POST['select'] == 'student_code') {echo 'selected';}} ?>>รหัสนักศึกษา</option>
              <option value="student_name" <?php if (isset($_POST['select'])) {if ($_POST['select'] == 'student_name') {echo 'selected';}} ?>>ชื่อ</option>
            </select>
          </div>
          <div class="col col-lg-2">
            <select class="form-select" name="term" required>
              <option value="" selected disabled> -- เลือกภาคเรียน -- </option>
              <option value="term1" <?php if (isset($_POST['term'])) {if ($_POST['term'] == 'term1') {echo 'selected';}} ?>>1</option>
              <option value="term2" <?php if (isset($_POST['term'])) {if ($_POST['term'] == 'term2') {echo 'selected';}} ?>>2</option>
            </select>
          </div>
          <div class="col">
            <input type="text" class="form-control" name="value" value="<?php if (isset($_POST['value'])) {echo $_POST['value'];} ?>" required/>
          </div>
          <div class="col-md-auto">
            <button type="submit" name="submit" class="btn btn-success">ค้นหา</button>
          </div>
        </form>
        <?php
         //echo $_POST['term'];
        if (isset($_POST['submit'])) {
          $num = 1;
          if(isset($_POST['term']))
          {
            if($_POST['term']=='term1')
            {
              $term=1;
              //echo "Term : ".$term;
              //สั่ง sql ตารางเทอม1
              $sql = "SELECT * FROM tb_gstudentmt1 INNER JOIN tb_class ON (tb_gstudentmt1 .student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
            }
            if($_POST['term']=='term2')
            {
              $term=2;
              //echo "Term : ".$term;
              //สั่ง sql ตารางเทอม2
              $sql = "SELECT * FROM tb_gstudentmt2 INNER JOIN tb_class ON (tb_gstudentmt2.student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
            }
          }
          $query = mysqli_query($Connection,$sql);
          $check_data = mysqli_num_rows($query);
          //echo " Check_data: ".$check_data;
          if ($check_data == 0) {
            echo '<p class="text-center py-4"><span class="badge bg-danger" style="font-size: 20px;">ไม่พบข้อมูล</span></p>';
          }else{
            ?>
            <table class="table table-bordered mt-4">
              <thead class="table-secondary">
                <tr>
                  <!--<th scope="col" class="text-center">ลำดับที่</th>-->
                  <th scope="col" class="text-center">รหัสนักนักเรียน</th>
                  <th scope="col" class="text-center">ชื่อ - นามสกุล</th>
                  <th scope="col" class="text-center">ระดับชั้น</th>
                  <!--<th scope="col" class="text-center">ดูผลการเรียน</th>-->
                </tr>
              </thead>
              <tbody>
                <?php
                while ($result = mysqli_fetch_array($query)) {
                  ?>
                  <tr>
                    <!--<td class="text-center"><?php echo $num++; ?></td>-->
                    <td class="text-center"><?php echo $result['student_code']; ?></td>
                    <td><?php echo $result['student_prefix'].$result['student_name']; ?></td>
                    <td><?php echo $result['Name_Class']; ?></td>
                    <!--<td class="text-center"><?php //echo "คลิก";?></td>-->
                  </tr>
                  <?php
                }
                ?>
              </tbody>
            </table>
            <?php /* ตรวจสอบ ส่งค่า term*/
            if(isset($_POST['term']))
            {
              if($_POST['term']=='term1')
              {
                $term=1;
                //echo "Term : ".$term;
                //สั่ง sql ตารางเทอม1
                $sql = "SELECT * FROM tb_gstudentmt1 INNER JOIN tb_class ON (tb_gstudentmt1.student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
              }elseif($_POST['term']=='term2')
              {
                $term=2;
                //echo "Term : ".$term;
                //สั่ง sql ตารางเทอม2
                $sql = "SELECT * FROM tb_gstudentmt2 INNER JOIN tb_class ON (tb_gstudentmt2.student_id_class=tb_class.Id_Class) WHERE ".$_POST['select']." LIKE '".$_POST['value']."%'";
              }
            }
            $query = mysqli_query($Connection,$sql);
            $check_data = mysqli_num_rows($query);
            while ($result = mysqli_fetch_array($query)) {
              ?>

            <table class="table table-bordered mt-4">
              <thead class="table-secondary">
                <tr>
                  <td colspan="3" class="text-center bg-info">แสดงผลการเรียนภาคเรียนที่ : <?php echo $term ."  ".$result['student_prefix'].$result['student_name'];?></td></tr>
              </thead>
              <tbody>
                  <tr>
                  <td class="text-center bg-warning fw-bold" width="70%"><?php echo "วิชา"; ?></td>
                  <td class="text-center bg-warning fw-bold" width="30%"><?php echo "หน่วยกิต"; ?></td>
                  <td class="text-center bg-warning fw-bold" width="30%"><?php echo "เกรด"; ?></td>
                  </tr>
                  <thead class="table-secondary">
                  <tr>
                  <td colspan="3" class="bg-light text-center">รายวิชาพื้นฐาน</td></tr>
                  </thead>
                  <tr>
                  <td><?php echo "ภาษาไทย"; ?></td>
                  <td class="text-center"><?php $Credit_thai=1.5;
                        $thai=$result['subject_thai']*$Credit_thai;
                        echo "&nbsp;". $Credit_thai;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_thai']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "คณิตศาสตร์"; ?></td>
                  <td class="text-center"><?php $Credit_math=1.5;
                        $math=$result['subject_math']*$Credit_math;
                        echo "&nbsp;". $Credit_math;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_math']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "วิทยาศาสตร์";?></td>
                  <td class="text-center"><?php $Credit_science=1.0;
                        $science=$result['subject_science']*$Credit_science;
                        echo "&nbsp;". $Credit_science;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_science']; ?></td>
                  </tr> 
                  <tr>
                  <td><?php if($term==1){ echo "วิทยาศาสตร์และเทคโนโลยี(วิทยาการคำนวณ)";} 
                            if($term==2){ echo "วิทยาศาสตร์และเทคโนโลยี(การออกแบบและเทคโนโลยี)";}?>
                  </td>
                  <td class="text-center"><?php $Credit_com_science=0.5;
                        $com_science=$result['subject_com_science']*$Credit_com_science;
                        echo "&nbsp;". $Credit_com_science;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_com_science']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "สังคมศึกษา ศาสนาและวัฒนธรรม";?></td>
                  <td class="text-center"><?php $Credit_social=1.5;
                        $social=$result['subject_social']*$Credit_social;
                        echo "&nbsp;". $Credit_social;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_social']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "ประวัติศาสตร์"; ?></td>
                  <td class="text-center"><?php $Credit_history=0.5;
                        $history=$result['subject_history']*$Credit_history;
                        echo "&nbsp;". $Credit_history;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_history']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "สุขศึกษา"; ?></td>
                  <td class="text-center"><?php $Credit_health=0.5;
                        $health=$result['subject_health']*$Credit_health;
                        echo "&nbsp;". $Credit_health;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_health']; ?></td>
                  </tr>
                  <tr>
                  <td><?php if($result['student_id_class']==9 && $term==1){ echo"พลศึกษา(ยืดยุ่น)";}
                            if($result['student_id_class']==9 && $term==2){echo "พลศึกษา(เทเบิลเทนนิส)";}
                            if($result['student_id_class']==10 && $term==1){echo "พลศึกษา(กรีฑา)";}
                            if($result['student_id_class']==10 && $term==2){echo "พลศึกษา(ตะกร้อ)";}
                            if($result['student_id_class']==11 && $term==1){echo "พลศึกษา(วอลเล่ย์บอล)";}
                            if($result['student_id_class']==11 && $term==2){echo "พลศึกษา(ฟุตบอล)";}
                      ?>
                  </td>
                  <td class="text-center"><?php $Credit_gymnastics=0.5;
                        $gymnastics=$result['subject_gymnastics']*$Credit_gymnastics;
                        echo "&nbsp;". $Credit_gymnastics;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_gymnastics']; ?></td>
                  </tr>
                  <tr>
                  <td><?php if(($result['student_id_class']==9 or $result['student_id_class']==10 or $result['student_id_class']==11) && $term==1){ echo"ศิลปะ(ทัศนศิลป์)";}
                            if(($result['student_id_class']==9 or $result['student_id_class']==10 or $result['student_id_class']==11) && $term==2){echo "ศิลปะ(ดนตรี-นาฏศิลป์)";}
                      ?>
                  </td>
                  <td class="text-center"><?php $Credit_art=1.0;
                        $art=$result['subject_art']*$Credit_art;
                        echo "&nbsp;". $Credit_art;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_art']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "การงานอาชีพ";?></td>
                  <td class="text-center"><?php $Credit_job=1.0;
                        $job=$result['subject_job']*$Credit_job;
                        echo "&nbsp;". $Credit_job;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_job']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "ภาษาต่างประเทศ(ภาษาอังกฤษ)";?></td>
                  <td class="text-center"><?php $Credit_eng=1.5;
                        $eng=$result['subject_eng']*$Credit_eng;
                        echo "&nbsp;". $Credit_eng;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_eng']; ?></td>
                  </tr>
                  <thead class="table-secondary">
                  <tr>
                  <td colspan="3" class="bg-light text-center">รายวิชาเพิ่มเติม</td></tr>
                  </thead>
                  <tr>
                  <td><?php echo "ภาษาไทย(เพิ่มเติม)";?></td>
                  <td class="text-center"><?php $Credit_thaiP=0.5;
                        $thaiP=$result['subject_thaiP']*$Credit_thaiP;
                        echo "&nbsp;". $Credit_thaiP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_thaiP']; ?></td>
                  </tr>
                  <tr>
                  <td><?php echo "คณิตศาสตร์(เพิ่มเติม)"; ?></td>
                  <td class="text-center"><?php $Credit_mathP=0.5;
                        $mathP=$result['subject_mathP']*$Credit_mathP;
                        echo "&nbsp;". $Credit_mathP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_mathP'];?></td>
                  </tr>
                  <tr>
                  <td><?php echo "วิทยาศาสตร์และเทคโนโลยี คอมพิวเตอร์(เพิ่มเติม)"; ?></td>
                  <td class="text-center"><?php $Credit_computerP=0.5;
                        $computerP=$result['subject_computerP']*$Credit_computerP;
                        echo "&nbsp;". $Credit_computerP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_computerP'];?></td>
                  </tr>
                  <tr>
                  <td><?php if($result['student_id_class']==9 && $term==1 or $result['student_id_class']==9 && $term==2){ echo"วิทยาศาสตร์และเทคโนโลยี หุ่นยนต์พื้นฐาน(เพิ่มเติม))";}
                            if($result['student_id_class']==10 && $term==1 or $result['student_id_class']==10 && $term==2){echo "วิทยาศาสตร์และเทคโนโลยี หุ่นยนต์อัตโนมัติ(เพิ่มเติม)";}
                            if($result['student_id_class']==11 && $term==1 or $result['student_id_class']==11 && $term==2){echo "วิทยาศาสตร์และเทคโนโลยี หุ่นยนต์นวัตกรรมและIOT(เพิ่มเติม)";}
                      ?>
                  </td>
                  <td class="text-center"><?php $Credit_robotP=0.5;
                        $robotP=$result['subject_robotP']*$Credit_robotP;
                        echo "&nbsp;". $Credit_robotP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_robotP'];?></td>
                  </tr>
                  <tr>
                  <td><?php echo "หน้าที่พลเมือง(เพิ่มเติม)"; ?></td>
                  <td class="text-center"><?php $Credit_dutyP=0.5;
                        $dutyP=$result['subject_dutyP']*$Credit_dutyP;
                        echo "&nbsp;". $Credit_dutyP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_dutyP'];?></td>
                  </tr>
                  <tr>
                  <td><?php echo "พระพุทธศาสนา(เพิ่มเติม)"; ?></td>
                  <td class="text-center"><?php $Credit_buddhaP=0.5;
                        $buddhaP=$result['subject_buddhaP']*$Credit_buddhaP;
                        echo "&nbsp;". $Credit_buddhaP;
                      ?>
                  </td>
                  <td class="text-center"><?php echo $result['subject_buddhaP'];?></td>
                  </tr>
                  <tr>
                  <td class="bg-info text-center fw-bold"><?php echo "เกรดเฉลี่ย"; ?></td>
                  <td class="bg-info text-center fw-bold">
                    <?php /*กำหนดตัวแปรเก็บหน่วยกิตทั้งหมด sumCredit*/ 
                    $sumCredit=$Credit_thai+$Credit_math+$Credit_science+$Credit_com_science+$Credit_social+$Credit_history+$Credit_health+$Credit_gymnastics+$Credit_art+$Credit_job+$Credit_eng+$Credit_thaiP+$Credit_mathP+$Credit_computerP+$Credit_robotP+$Credit_dutyP+$Credit_buddhaP; 
                    ?>
                     <?php  echo "รวม : " .$sumCredit." หน่วยกิต"; ?>
                  </td>
                  <td class="text-center fw-bold">
                    <?php
                    /*กำหนดตัวแปรเก็บผลหน่วยกิตที่ได้ (เกรดxหน่วยกิต) sumUnit*/ 
                    $sumUnit=$thai+$math+$science+$com_science+$social+$history+$health+$gymnastics+$art+$job+$eng+$thaiP+$mathP+$computerP+$robotP+$dutyP+$buddhaP; /*รวมหน่วยที่ได้*/ echo number_format($sumUnit/$sumCredit, 2, '.', ''); //echo "<br>หน่วยกิตทั้งหมด" .$sumCredit."<br>ผลคูณหน่วยกิตรวม". $sumUnit;
                    ?>
                  </td> 
                  </tr>
                  <?php
                }
                ?>
              </tbody>
            </table>
            <?php
          }
        }
      }
        ?>
      </div>
    </div>
  </div>
  <script src="assets/js/bootstrap.bundle.min.js"></script>
  <?php mysqli_close($Connection);?>
  <?php include 'includes/foot.php';?>
</body>
</html>