Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将foreach()Mysql select转换为HTML格式_Php_Html_Sql - Fatal编程技术网

Php 如何将foreach()Mysql select转换为HTML格式

Php 如何将foreach()Mysql select转换为HTML格式,php,html,sql,Php,Html,Sql,我正在研究一个小型课程注册系统。我有一张名为20182019carryovertbl的表格,我从表格中选择了学生,表格运行良好。我需要使用submit按钮将所选信息转换为HTML表单(这将进入另一个表20192020coursestbl)。如何设置输入的名称 <table> <thead> <tr> <th>Register course</th> <th>Course Title<

我正在研究一个小型课程注册系统。我有一张名为20182019carryovertbl的表格,我从表格中选择了学生,表格运行良好。我需要使用submit按钮将所选信息转换为HTML表单(这将进入另一个表20192020coursestbl)。如何设置输入的名称

<table>
  <thead>
    <tr>
      <th>Register course</th>
      <th>Course Title</th>
      <th>Corse Code</th>
      <th>Unit</th>
      <th>Lecturer</th>
    </tr>
  </thead>

  <tbody>

    <?php $sql = "SELECT * from  20182019carryovertbl WHERE matricno = '$matno' ";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{               ?>
    <tr>
      <td> <input type="checkbox" name="reg1" value="1" class="custom-control-input"></td>
      <td>
        <?php echo htmlentities($result->coursetitle);?>
      </td>
      <td>
        <?php echo htmlentities($result->coursecode);?>
      </td>
      <td>
        <?php echo htmlentities($result->unit);?>
      </td>
      <td>
        <?php echo htmlentities($result->lecturer);?>
      </td>

    </tr>
    <?php $cnt=$cnt+1; }} ?>

  </tbody>
</table>

注册课程
课程名称
科塞代码
单位
讲师

您可以使用数据库中的唯一密钥,如Id:

<td> 
  <input type="checkbox" name="reg<?php echo $result->id;" value="1"class="custom-control-input">
</td>