PHP - 过滤"主题名称" &安培; "科目成绩"并显示课程结果

时间:2016-02-04 23:50:02

标签: php

我要开发一个系统让我的用户输入他们的中学成绩,我的系统会显示一个结果,向他们展示他们有资格在文凭级别申请的课程。

我为这个系统准备了两页checkresult.phpcheckresult2.phpcheckresult.php是一个表格,由主题选项组成,而checkresult2.php是显示结果的页面。

我不知道如何根据主题名称及其成绩进行过滤,任何人都有一些想法作为参考?

这是我对checkresult.php的编码:

<form action="checkresult2.php">
    <table class="p1" bgcolor="#FFFFCC" bordercolor="#000000" align="center" width="771" border="2">
          <tr>
              <td><div align="center"><strong>No.</strong></div></td>
              <td><div align="center"><strong>Subject Name</strong></div></td>
              <td><div align="center"><strong>Grade</strong></div></td>
          </tr>

            <?php 
          for($i=1; $i<=10; $i++)
          {?>
          <tr>
              <td width="44"><div align="center"><?php echo $i; ?></div></td>
              <td width="601">
                  <select name="subj[]">
                      <option value="">--- Please choose a subject ---</option>
                          <?php
                          $result = mysql_query("SELECT * FROM spm_subject");
                          while($s = mysql_fetch_assoc($result))
                          {?>
                              <option value="<?php echo $s['name']; ?>"><?php echo $s["name"]; ?></option>
                      <?php } ?>
                  </select>
              </td>
              <td width="104"><div align="center">
                  <select name="grad[]">
                      <option value="">&nbsp;</option>
                          <?php
                          $result2 = mysql_query("SELECT * FROM spm_grade");
                          while($g = mysql_fetch_assoc($result2))
                          {?>
                              <option value="<?php echo $g['grade']; ?>"><?php echo $g["grade"]; ?></option>
                      <?php } ?>
                  </select>
              </div>
              </td>
          </tr>
            <?php }?>
          <tr>
              <td colspan="3">
                  <div align="center">
                      <input type="submit" value="Submit">
                  </div>
              </td>
          </tr>
    </table>
</form>

我只知道为我的checkresult2.php执行此操作:(我的想法)

<?php
    function result1() //Function to display eligible courses
    {
        //Smth else....
    }

    function result2() //Function to display non-eligible courses
    { 
        echo "<table border='1' style='width:auto'>";
        echo "<tr><td>Programme Name</td><td>Result</td></tr>";
        echo "<tr><td>Diploma in Information Technology (Programming)</td><td>NOT QUALIFIED</td></tr>";
        echo "<tr><td>Diploma in Information Technology (Networking)</td><td>NOT QUALIFIED</td></tr>";
        echo "<tr><td>Diploma in Information Technology (Information Security)</td><td>NOT QUALIFIED</td></tr>";
        echo "</table>";
    }

    if ("first subject grade" == "A+" || "A-" || "A" || "B+" || "B" || "C+" || "C")
    {
        if ("second subject grade"  == "A+" || "A-" || "A" || "B+" || "B" || "C+" || "C")
        {
            if ("third subject grade"  == "A+" || "A-" || "A" || "B+" || "B" || "C+" || "C")
            {
                if ("forth subject grade"  == "A+" || "A-" || "A" || "B+" || "B" || "C+" || "C")
                {
                    result1();
                }
                else
                {
                    result2();
                }
            }
            else
            {
                result2();
            }
        }
        else
        {
            result2();
        }
    }
    else
    {
        result2();
    }

?>

0 个答案:

没有答案