如何在提交表单后仍选择下拉菜单值(2)?

发布于 2024-12-10 02:47:02 字数 6828 浏览 0 评论 0原文

可能的重复:
如何获取提交表单后下拉菜单值仍然处于选中状态?

当我在文本框中输入数据并提交表单时,数据仍然存储在文本框中,这很好,例如我使用了 .我现在想做的是,当从下拉菜单中选择一个值并提交表单时,我希望所选值仍显示为下拉列表中的所选值,但我无法做到这一点。有什么想法吗?

下面是代码:

<!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>

<title>Exam Interface</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<?php

$username="xxx";
$password="xxx";
$database="mobile_app";

mysql_connect('localhost',$username,$password);

@mysql_select_db($database) or die("Unable to select database");



$sessionid = isset ($_POST['sessionid']) ? $_POST['sessionid'] : "";
$moduleid = isset ($_POST['moduleid']) ? $_POST['moduleid'] : "";
$teacherid = isset ($_POST['teacherid']) ? $_POST['teacherid'] : "";
$studentid = isset ($_POST['studentid']) ? $_POST['studentid'] : "";
$grade = isset ($_POST['grade']) ? $_POST['grade'] : "";
$orderfield = isset ($_POST['order']) ? $_POST['order'] : "";

$sessionid = mysql_real_escape_string($sessionid);
$moduleid = mysql_real_escape_string($moduleid);
$teacherid = mysql_real_escape_string($teacherid);
$studentid = mysql_real_escape_string($studentid);
$grade = mysql_real_escape_string($grade);

?>

<p><strong>NOTE: </strong>If a search box is left blank, then the form will search for all data under that specific field</p>

<form action="exam_interface.php" method="post" name="sessionform">        <!-- This will post the form to its own page"-->
<p>Session ID: <input type="text" name="sessionid" value="<?PHP print $sessionid ; ?>" /></p>      <!-- Enter Session Id here-->
<p>Module Number: <input type="text" name="moduleid" value="<?PHP print $moduleid ; ?>" /></p>      <!-- Enter Module Id here-->
<p>Teacher Username: <input type="text" name="teacherid" value="<?PHP print $teacherid ; ?>" /></p>      <!-- Enter Teacher here-->
<p>Student Username: <input type="text" name="studentid" value="<?PHP print $studentid ; ?>" /></p>      <!-- Enter User Id here-->
<p>Grade: <input type="text" name="grade" value="<?PHP print $grade ; ?>" /></p>      <!-- Enter Grade here-->
<p>Order Results By: <select name="order" value="<?PHP print $orderfield ; ?>">
<option value="ordersessionid">Session ID</option>
<option value="ordermoduleid">Module Number</option>
<option value="orderteacherid">Teacher Username</option>
<option value="orderstudentid">Student Username</option>
<option value="ordergrade">Grade</option>
</select>
<p><input type="submit" value="Submit" name="submit" /></p>
</form>

<?php

$username="u0867587";
$password="31may90";
$database="mobile_app";

mysql_connect('localhost',$username,$password);

@mysql_select_db($database) or die("Unable to select database");



$sessionid = isset ($_POST['sessionid']) ? $_POST['sessionid'] : "";
$moduleid = isset ($_POST['moduleid']) ? $_POST['moduleid'] : "";
$teacherid = isset ($_POST['teacherid']) ? $_POST['teacherid'] : "";
$studentid = isset ($_POST['studentid']) ? $_POST['studentid'] : "";
$grade = isset ($_POST['grade']) ? $_POST['grade'] : "";
$orderfield = isset ($_POST['order']) ? $_POST['order'] : "";

$sessionid = mysql_real_escape_string($sessionid);
$moduleid = mysql_real_escape_string($moduleid);
$teacherid = mysql_real_escape_string($teacherid);
$studentid = mysql_real_escape_string($studentid);
$grade = mysql_real_escape_string($grade);

if(isset($_POST['submit'])) {

switch ($orderfield) {
    case 'ordersessionid': $orderfield = 'gr.SessionId';
    break;
    case 'ordermoduleid': $orderfield = 'm.ModuleId'; 
    break;
    case 'orderteacherid': $orderfield = 's.TeacherId';
    break;
    case 'orderstudentid': $orderfield = 'gr.StudentId'; 
    break;
    case 'ordergrade': $orderfield = 'gr.Grade';
    break;
}

$result = mysql_query("SELECT * FROM Module m INNER JOIN Session s ON m.ModuleId = s.ModuleId JOIN Grade_Report gr ON s.SessionId = gr.SessionId JOIN Student st ON gr.StudentId = st.StudentId WHERE ('$sessionid' = '' OR gr.SessionId = '$sessionid') AND ('$moduleid' = '' OR m.ModuleId = '$moduleid') AND ('$teacherid' = '' OR s.TeacherId = '$teacherid') AND ('$studentid' = '' OR gr.StudentId = '$studentid') AND ('$grade' = '' OR gr.Grade = '$grade') ORDER BY $orderfield ASC");

$num=mysql_numrows($result);

echo "<p>Your Search: <strong>Session ID:</strong> "; if (empty($sessionid))echo "'All Sessions'"; else echo "'$sessionid'";echo ", <strong>Module ID:</strong> "; if (empty($moduleid))echo "'All Modules'"; else echo "'$moduleid'";echo ", <strong>Teacher Username:</strong> "; if (empty($teacherid))echo "'All Teachers'"; else echo "'$teacherid'";echo ", <strong>Student Username:</strong> "; if (empty($studentid))echo "'All Students'"; else echo "'$studentid'";echo ", <strong>Grade:</strong> "; if (empty($grade))echo "'All Grades'"; else echo "'$grade'"; echo ", <strong>Order Results By:</strong>";if ($orderfield == 'gr.SessionId') echo " 'Session ID'"; else if ($orderfield == 'm.ModuleId') echo " 'Module Number' "; else if ($orderfield == 's.TeacherId') echo " 'Teacher Username' "; else if ($orderfield == 'gr.StudentId') echo " 'Student Username' "; else if ($orderfield == 'gr.Grade') echo " 'Grade' ";"</p>";

echo "<p>Number of Records Shown in Result of the Search: <strong>$num</strong></p>";

echo "<table border='1'>
<tr>
<th>Student Id</th>
<th>Forename</th>
<th>Session Id</th>
<th>Grade</th>
<th>Mark</th>
<th>Module</th>
<th>Teacher</th>
</tr>";

while ($row = mysql_fetch_array($result)){

 echo "<tr>";
  echo "<td>" . $row['StudentId'] . "</td>";
  echo "<td>" . $row['Forename'] . "</td>";
  echo "<td>" . $row['SessionId'] . "</td>";
  echo "<td>" . $row['Grade'] . "</td>";
  echo "<td>" . $row['Mark'] . "</td>";
  echo "<td>" . $row['ModuleName'] . "</td>";
  echo "<td>" . $row['TeacherId'] . "</td>";
  echo "</tr>";
}

echo "</table>";

}

mysql_close();


 ?>

</body>
</html>

谢谢

Possible Duplicate:
How can I get drop down menu value still selected after form is submitted?

When I type in data in a text box and submit the form, the data is still stored in the text box which is great For example I used . What I want to do now is that when a value is selected from a drop down menu and the form is submitted, I want the value chosen to still be shown as the selected value on the drop down list but I cannot manage to do this. Any ideas?

Below is the code:

<!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>

<title>Exam Interface</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<?php

$username="xxx";
$password="xxx";
$database="mobile_app";

mysql_connect('localhost',$username,$password);

@mysql_select_db($database) or die("Unable to select database");



$sessionid = isset ($_POST['sessionid']) ? $_POST['sessionid'] : "";
$moduleid = isset ($_POST['moduleid']) ? $_POST['moduleid'] : "";
$teacherid = isset ($_POST['teacherid']) ? $_POST['teacherid'] : "";
$studentid = isset ($_POST['studentid']) ? $_POST['studentid'] : "";
$grade = isset ($_POST['grade']) ? $_POST['grade'] : "";
$orderfield = isset ($_POST['order']) ? $_POST['order'] : "";

$sessionid = mysql_real_escape_string($sessionid);
$moduleid = mysql_real_escape_string($moduleid);
$teacherid = mysql_real_escape_string($teacherid);
$studentid = mysql_real_escape_string($studentid);
$grade = mysql_real_escape_string($grade);

?>

<p><strong>NOTE: </strong>If a search box is left blank, then the form will search for all data under that specific field</p>

<form action="exam_interface.php" method="post" name="sessionform">        <!-- This will post the form to its own page"-->
<p>Session ID: <input type="text" name="sessionid" value="<?PHP print $sessionid ; ?>" /></p>      <!-- Enter Session Id here-->
<p>Module Number: <input type="text" name="moduleid" value="<?PHP print $moduleid ; ?>" /></p>      <!-- Enter Module Id here-->
<p>Teacher Username: <input type="text" name="teacherid" value="<?PHP print $teacherid ; ?>" /></p>      <!-- Enter Teacher here-->
<p>Student Username: <input type="text" name="studentid" value="<?PHP print $studentid ; ?>" /></p>      <!-- Enter User Id here-->
<p>Grade: <input type="text" name="grade" value="<?PHP print $grade ; ?>" /></p>      <!-- Enter Grade here-->
<p>Order Results By: <select name="order" value="<?PHP print $orderfield ; ?>">
<option value="ordersessionid">Session ID</option>
<option value="ordermoduleid">Module Number</option>
<option value="orderteacherid">Teacher Username</option>
<option value="orderstudentid">Student Username</option>
<option value="ordergrade">Grade</option>
</select>
<p><input type="submit" value="Submit" name="submit" /></p>
</form>

<?php

$username="u0867587";
$password="31may90";
$database="mobile_app";

mysql_connect('localhost',$username,$password);

@mysql_select_db($database) or die("Unable to select database");



$sessionid = isset ($_POST['sessionid']) ? $_POST['sessionid'] : "";
$moduleid = isset ($_POST['moduleid']) ? $_POST['moduleid'] : "";
$teacherid = isset ($_POST['teacherid']) ? $_POST['teacherid'] : "";
$studentid = isset ($_POST['studentid']) ? $_POST['studentid'] : "";
$grade = isset ($_POST['grade']) ? $_POST['grade'] : "";
$orderfield = isset ($_POST['order']) ? $_POST['order'] : "";

$sessionid = mysql_real_escape_string($sessionid);
$moduleid = mysql_real_escape_string($moduleid);
$teacherid = mysql_real_escape_string($teacherid);
$studentid = mysql_real_escape_string($studentid);
$grade = mysql_real_escape_string($grade);

if(isset($_POST['submit'])) {

switch ($orderfield) {
    case 'ordersessionid': $orderfield = 'gr.SessionId';
    break;
    case 'ordermoduleid': $orderfield = 'm.ModuleId'; 
    break;
    case 'orderteacherid': $orderfield = 's.TeacherId';
    break;
    case 'orderstudentid': $orderfield = 'gr.StudentId'; 
    break;
    case 'ordergrade': $orderfield = 'gr.Grade';
    break;
}

$result = mysql_query("SELECT * FROM Module m INNER JOIN Session s ON m.ModuleId = s.ModuleId JOIN Grade_Report gr ON s.SessionId = gr.SessionId JOIN Student st ON gr.StudentId = st.StudentId WHERE ('$sessionid' = '' OR gr.SessionId = '$sessionid') AND ('$moduleid' = '' OR m.ModuleId = '$moduleid') AND ('$teacherid' = '' OR s.TeacherId = '$teacherid') AND ('$studentid' = '' OR gr.StudentId = '$studentid') AND ('$grade' = '' OR gr.Grade = '$grade') ORDER BY $orderfield ASC");

$num=mysql_numrows($result);

echo "<p>Your Search: <strong>Session ID:</strong> "; if (empty($sessionid))echo "'All Sessions'"; else echo "'$sessionid'";echo ", <strong>Module ID:</strong> "; if (empty($moduleid))echo "'All Modules'"; else echo "'$moduleid'";echo ", <strong>Teacher Username:</strong> "; if (empty($teacherid))echo "'All Teachers'"; else echo "'$teacherid'";echo ", <strong>Student Username:</strong> "; if (empty($studentid))echo "'All Students'"; else echo "'$studentid'";echo ", <strong>Grade:</strong> "; if (empty($grade))echo "'All Grades'"; else echo "'$grade'"; echo ", <strong>Order Results By:</strong>";if ($orderfield == 'gr.SessionId') echo " 'Session ID'"; else if ($orderfield == 'm.ModuleId') echo " 'Module Number' "; else if ($orderfield == 's.TeacherId') echo " 'Teacher Username' "; else if ($orderfield == 'gr.StudentId') echo " 'Student Username' "; else if ($orderfield == 'gr.Grade') echo " 'Grade' ";"</p>";

echo "<p>Number of Records Shown in Result of the Search: <strong>$num</strong></p>";

echo "<table border='1'>
<tr>
<th>Student Id</th>
<th>Forename</th>
<th>Session Id</th>
<th>Grade</th>
<th>Mark</th>
<th>Module</th>
<th>Teacher</th>
</tr>";

while ($row = mysql_fetch_array($result)){

 echo "<tr>";
  echo "<td>" . $row['StudentId'] . "</td>";
  echo "<td>" . $row['Forename'] . "</td>";
  echo "<td>" . $row['SessionId'] . "</td>";
  echo "<td>" . $row['Grade'] . "</td>";
  echo "<td>" . $row['Mark'] . "</td>";
  echo "<td>" . $row['ModuleName'] . "</td>";
  echo "<td>" . $row['TeacherId'] . "</td>";
  echo "</tr>";
}

echo "</table>";

}

mysql_close();


 ?>

</body>
</html>

Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没企图 2024-12-17 02:47:02

这是我的页面版本,有太多更改无法提及。如果有什么不明白的地方,欢迎提问...

<!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>
    <title>Exam Interface</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>

  <body>
    <?php

      $username="xxx";
      $password="xxx";
      $database="mobile_app";

      mysql_connect('localhost',$username,$password);
      @mysql_select_db($database) or die("Unable to select database");

      foreach (array('sessionid','moduleid','teacherid','studentid','grade','orderfield') as $varname) {
        $varname = (isset($_POST[$varname])) ? $_POST[$varname] : '';
      }

      switch ($orderfield) {
        case 'ordersessionid':
          $orderfield = 'gr.SessionId';
          $ordername = 'Session ID';
          break;
        case 'ordermoduleid':
          $orderfield = 'm.ModuleId'; 
          $ordername = 'Module Number';
          break;
        case 'orderteacherid':
          $orderfield = 's.TeacherId';
          $ordername = 'Teacher Username';
          break;
        case 'orderstudentid':
          $orderfield = 'gr.StudentId'; 
          $ordername = 'Student Username';
          break;
        case 'ordergrade':
        default:
          $orderfield = 'gr.Grade';
          $ordername = 'Grade';
          break;
      }

    ?>
    <p><strong>NOTE: </strong>If a search box is left blank, then the form will search for all data under that specific field</p>

    <form action="exam_interface.php" method="post" name="sessionform">        <!-- This will post the form to its own page"-->
      <p>Session ID: <input type="text" name="sessionid" value="<?php echo $sessionid; ?>" /></p>      <!-- Enter Session Id here-->
      <p>Module Number: <input type="text" name="moduleid" value="<?php echo $moduleid; ?>" /></p>      <!-- Enter Module Id here-->
      <p>Teacher Username: <input type="text" name="teacherid" value="<?php echo $teacherid; ?>" /></p>      <!-- Enter Teacher here-->
      <p>Student Username: <input type="text" name="studentid" value="<?php echo $studentid; ?>" /></p>      <!-- Enter User Id here-->
      <p>Grade: <input type="text" name="grade" value="<?php echo $grade; ?>" /></p>      <!-- Enter Grade here-->
      <p>Order Results By:
        <select name="orderfield">
          <option value="ordersessionid"<?php if ($orderfield == 'ordersessionid') echo ' selected="selected"' ?>>Session ID</option>
          <option value="ordermoduleid"<?php if ($orderfield == 'ordermoduleid') echo ' selected="selected"' ?>>Module Number</option>
          <option value="orderteacherid"<?php if ($orderfield == 'orderteacherid') echo ' selected="selected"' ?>>Teacher Username</option>
          <option value="orderstudentid"<?php if ($orderfield == 'orderstudentid') echo ' selected="selected"' ?>>Student Username</option>
          <option value="ordergrade"<?php if ($orderfield == 'ordergrade') echo ' selected="selected"' ?>>Grade</option>
        </select>
      </p>
      <p><input type="submit" value="Submit" name="submit" /></p>
    </form>

    <?php
      if (isset($_POST['submit'])) {

        $query = "
          SELECT * FROM Module m
            INNER JOIN Session s ON m.ModuleId = s.ModuleId
            JOIN Grade_Report gr ON s.SessionId = gr.SessionId
            JOIN Student st ON gr.StudentId = st.StudentId
          WHERE
            ('".mysql_real_escape_string($sessionid)."' = '' OR gr.SessionId = '".mysql_real_escape_string($sessionid)."')
          AND
            ('".mysql_real_escape_string($moduleid)."' = '' OR m.ModuleId = '".mysql_real_escape_string($moduleid)."')
          AND
            ('".mysql_real_escape_string($teacherid)."' = '' OR s.TeacherId = '".mysql_real_escape_string($teacherid)."')
          AND
            ('".mysql_real_escape_string($studentid)."' = '' OR gr.StudentId = '".mysql_real_escape_string($studentid)."')
          AND
            ('".mysql_real_escape_string($grade)."' = '' OR gr.Grade = '".mysql_real_escape_string($grade)."')
          ORDER BY $orderfield ASC";

        $num = mysql_num_rows($result = mysql_query($query));
        mysql_close();

    ?>

    <p>
      Your Search:
      <strong>Session ID:</strong> <?php echo (empty($sessionid)) ? "'All Sessions'" : "'$sessionid'"; ?>,
      <strong>Module ID:</strong> <?php echo (empty($moduleid)) ? "'All Modules'" : "'$moduleid'"; ?>,
      <strong>Teacher Username:</strong> <?php echo (empty($teacherid)) ? "'All Teachers'" : "'$teacherid'"; ?>,
      <strong>Student Username:</strong> <?php echo (empty($studentid)) ? "'All Students'" : "'$studentid'"; ?>,
      <strong>Grade:</strong> <?php echo (empty($grade)) ? "'All Grades'" : "'$grade'"; ?>,
      <strong>Order Results By:</strong> '<?php echo $ordername; ?>'
    </p>
    <p>Number of Records Shown in Result of the Search: <strong><?php echo $num ?></strong></p>
    <table border='1'>
      <tr>
        <th>Student Id</th>
        <th>Forename</th>
        <th>Session Id</th>
        <th>Grade</th>
        <th>Mark</th>
        <th>Module</th>
        <th>Teacher</th>
      </tr>
      <?php
        while ($row = mysql_fetch_array($result)) {
          echo "
      <tr>
        <td>{$row['StudentId']}</td>
        <td>{$row['Forename']}</td>
        <td>{$row['SessionId']}</td>
        <td>{$row['Grade']}</td>
        <td>{$row['Mark']}</td>
        <td>{$row['ModuleName']}</td>
        <td>{$row['TeacherId']}</td>
      </tr>";
        }
      ?>
    </table>

    <?php
      }
    ?>

  </body>
</html>

Here is my version of your page, with far too many changes to mention. If you don't understand anything, feel free to ask...

<!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>
    <title>Exam Interface</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>

  <body>
    <?php

      $username="xxx";
      $password="xxx";
      $database="mobile_app";

      mysql_connect('localhost',$username,$password);
      @mysql_select_db($database) or die("Unable to select database");

      foreach (array('sessionid','moduleid','teacherid','studentid','grade','orderfield') as $varname) {
        $varname = (isset($_POST[$varname])) ? $_POST[$varname] : '';
      }

      switch ($orderfield) {
        case 'ordersessionid':
          $orderfield = 'gr.SessionId';
          $ordername = 'Session ID';
          break;
        case 'ordermoduleid':
          $orderfield = 'm.ModuleId'; 
          $ordername = 'Module Number';
          break;
        case 'orderteacherid':
          $orderfield = 's.TeacherId';
          $ordername = 'Teacher Username';
          break;
        case 'orderstudentid':
          $orderfield = 'gr.StudentId'; 
          $ordername = 'Student Username';
          break;
        case 'ordergrade':
        default:
          $orderfield = 'gr.Grade';
          $ordername = 'Grade';
          break;
      }

    ?>
    <p><strong>NOTE: </strong>If a search box is left blank, then the form will search for all data under that specific field</p>

    <form action="exam_interface.php" method="post" name="sessionform">        <!-- This will post the form to its own page"-->
      <p>Session ID: <input type="text" name="sessionid" value="<?php echo $sessionid; ?>" /></p>      <!-- Enter Session Id here-->
      <p>Module Number: <input type="text" name="moduleid" value="<?php echo $moduleid; ?>" /></p>      <!-- Enter Module Id here-->
      <p>Teacher Username: <input type="text" name="teacherid" value="<?php echo $teacherid; ?>" /></p>      <!-- Enter Teacher here-->
      <p>Student Username: <input type="text" name="studentid" value="<?php echo $studentid; ?>" /></p>      <!-- Enter User Id here-->
      <p>Grade: <input type="text" name="grade" value="<?php echo $grade; ?>" /></p>      <!-- Enter Grade here-->
      <p>Order Results By:
        <select name="orderfield">
          <option value="ordersessionid"<?php if ($orderfield == 'ordersessionid') echo ' selected="selected"' ?>>Session ID</option>
          <option value="ordermoduleid"<?php if ($orderfield == 'ordermoduleid') echo ' selected="selected"' ?>>Module Number</option>
          <option value="orderteacherid"<?php if ($orderfield == 'orderteacherid') echo ' selected="selected"' ?>>Teacher Username</option>
          <option value="orderstudentid"<?php if ($orderfield == 'orderstudentid') echo ' selected="selected"' ?>>Student Username</option>
          <option value="ordergrade"<?php if ($orderfield == 'ordergrade') echo ' selected="selected"' ?>>Grade</option>
        </select>
      </p>
      <p><input type="submit" value="Submit" name="submit" /></p>
    </form>

    <?php
      if (isset($_POST['submit'])) {

        $query = "
          SELECT * FROM Module m
            INNER JOIN Session s ON m.ModuleId = s.ModuleId
            JOIN Grade_Report gr ON s.SessionId = gr.SessionId
            JOIN Student st ON gr.StudentId = st.StudentId
          WHERE
            ('".mysql_real_escape_string($sessionid)."' = '' OR gr.SessionId = '".mysql_real_escape_string($sessionid)."')
          AND
            ('".mysql_real_escape_string($moduleid)."' = '' OR m.ModuleId = '".mysql_real_escape_string($moduleid)."')
          AND
            ('".mysql_real_escape_string($teacherid)."' = '' OR s.TeacherId = '".mysql_real_escape_string($teacherid)."')
          AND
            ('".mysql_real_escape_string($studentid)."' = '' OR gr.StudentId = '".mysql_real_escape_string($studentid)."')
          AND
            ('".mysql_real_escape_string($grade)."' = '' OR gr.Grade = '".mysql_real_escape_string($grade)."')
          ORDER BY $orderfield ASC";

        $num = mysql_num_rows($result = mysql_query($query));
        mysql_close();

    ?>

    <p>
      Your Search:
      <strong>Session ID:</strong> <?php echo (empty($sessionid)) ? "'All Sessions'" : "'$sessionid'"; ?>,
      <strong>Module ID:</strong> <?php echo (empty($moduleid)) ? "'All Modules'" : "'$moduleid'"; ?>,
      <strong>Teacher Username:</strong> <?php echo (empty($teacherid)) ? "'All Teachers'" : "'$teacherid'"; ?>,
      <strong>Student Username:</strong> <?php echo (empty($studentid)) ? "'All Students'" : "'$studentid'"; ?>,
      <strong>Grade:</strong> <?php echo (empty($grade)) ? "'All Grades'" : "'$grade'"; ?>,
      <strong>Order Results By:</strong> '<?php echo $ordername; ?>'
    </p>
    <p>Number of Records Shown in Result of the Search: <strong><?php echo $num ?></strong></p>
    <table border='1'>
      <tr>
        <th>Student Id</th>
        <th>Forename</th>
        <th>Session Id</th>
        <th>Grade</th>
        <th>Mark</th>
        <th>Module</th>
        <th>Teacher</th>
      </tr>
      <?php
        while ($row = mysql_fetch_array($result)) {
          echo "
      <tr>
        <td>{$row['StudentId']}</td>
        <td>{$row['Forename']}</td>
        <td>{$row['SessionId']}</td>
        <td>{$row['Grade']}</td>
        <td>{$row['Mark']}</td>
        <td>{$row['ModuleName']}</td>
        <td>{$row['TeacherId']}</td>
      </tr>";
        }
      ?>
    </table>

    <?php
      }
    ?>

  </body>
</html>
ゞ花落谁相伴 2024-12-17 02:47:02
<p>Order Results By: <select name="order" value="<?PHP print $orderfield ; ?>">
<option value="ordersessionid" <?php echo ($_POST['name'] == 'ordersessionid') ? 'selected="true"' : ''; ?>>Session ID</option>
<option value="ordermoduleid"  <?php echo ($_POST['name'] == 'ordermoduleid') ? 'selected="true"' : ''; ?>>Module Number</option>
<option value="orderteacherid"  <?php echo ($_POST['name'] == 'orderteacherid') ? 'selected="true"' : ''; ?>>Teacher Username</option>
<option value="orderstudentid"  <?php echo ($_POST['name'] == 'orderstudentid') ? 'selected="true"' : ''; ?>>Student Username</option>
<option value="ordergrade"  <?php echo ($_POST['name'] == 'ordergrade') ? 'selected="true"' : ''; ?>>Grade</option>
</select>
<p>Order Results By: <select name="order" value="<?PHP print $orderfield ; ?>">
<option value="ordersessionid" <?php echo ($_POST['name'] == 'ordersessionid') ? 'selected="true"' : ''; ?>>Session ID</option>
<option value="ordermoduleid"  <?php echo ($_POST['name'] == 'ordermoduleid') ? 'selected="true"' : ''; ?>>Module Number</option>
<option value="orderteacherid"  <?php echo ($_POST['name'] == 'orderteacherid') ? 'selected="true"' : ''; ?>>Teacher Username</option>
<option value="orderstudentid"  <?php echo ($_POST['name'] == 'orderstudentid') ? 'selected="true"' : ''; ?>>Student Username</option>
<option value="ordergrade"  <?php echo ($_POST['name'] == 'ordergrade') ? 'selected="true"' : ''; ?>>Grade</option>
</select>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文