0

我试图弄清楚如何进行查询,根据教师希望临床进行的周数设置行(周数),这个值存储在一个名为临床的 Mysql 表中,列名是周(整数)。现在在我的 HTML 中,我刚刚粘贴了 4 行来向下看。我意识到我需要在这段代码之前连接到数据库

<table width="1000" border="1">
<tr>
    <td colspan="8" style="background-color:#1589FF;text-align:center;">
    <h1>Rating for the Week</h1>
    </td>
<tr>
    <th>Week</th>
    <th>Faculty Signature</th>
    <th>Rating for the Week <br>
        S+/S/NI/U</th>
    <th>Student Signature</th>
    <th>Rating for the Week <br>
        S+/S/NI/U</th>

</tr>
    <tr>
    <tr ALIGN="CENTER">
    <td>1</td>
    <td><form><input type = "submit" /></form></td> 
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
    <td><form><input type = "submit" /></form></td>
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
</tr>
    <tr>
    <tr ALIGN="CENTER">
    <td>2</td>
    <td><form><input type = "submit" /></form></td> 
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
    <td><form><input type = "submit" /></form></td>
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
</tr>
    <tr>
    <tr ALIGN="CENTER">
    <td>3</td>
    <td><form><input type = "submit" /></form></td> 
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
    <td><form><input type = "submit" /></form></td>
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
</tr>
<tr>
    <tr ALIGN="CENTER">
    <td>4</td>
    <td><form><input type = "submit" /></form></td> 
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
    <td><form><input type = "submit" /></form></td>
    <td><select>
        <option value="S+">S+</option>
        <option value="S">S</option>
        <option value="NI">NI</option>
        <option value="U">U</option>
        </select></td>
</tr>
<tr>
    <td colspan="8" style="background-color:#1589FF;text-align:center;">
    <b> The student must pass the clinical component of the course which is        ted on a pass/fail basis.<br>
    A clinical failure results in a grade of F for the course.<b>
    </td>
</tr>
    </table>
    </body>
    </html>
4

1 回答 1

0

查询将如下所示:

SELECT weeks FROM `clinical` WHERE clinicname = $clinicname

weeks该查询将从我添加了 WHERE 语句的表中选择列,clinical

因为如果有多个诊所,只要clinicname您的表中包含该列,它就会选择适当的一个。

要为每周创建一行,您将创建一个 while 循环,如下所示:

<?php 
$number_of_weeks_from_query = $query_result;
$i = 0;
while($i < $number_of_weeks_from_query){

INSERT EACH ROW TEMPLATE HERE AND CHANGE THE WEEK NUMBER TO $i

$i++;
}
?>

我建议使用 Mysql PDO,因为旧的 MySql 函数将很快被弃用。我还建议使用 AJAX,以便在有人点击提交按钮时保持页面加载。如果我做错了什么,请告诉我,我的 PHP 仍然生锈。

于 2013-04-02T01:54:24.720 回答