gpt4 book ai didi

javascript - 使用 html 表显示 MySql 数据

转载 作者:行者123 更新时间:2023-11-29 12:25:22 28 4
gpt4 key购买 nike

我有一个弹出表单,它从用户那里获取数据并将其添加到 MySQL phpmyadmin 表中,我希望能够在弹出窗口关闭后在 html 表中显示此数据,在我单击“提交”后,我被引导返回主页,我希望数据显示在表格上。

M.html

 <thead>    
<tr>
<th scope="col" colspan="2">CRN</th>
<th scope="col" colspan="6">Title</th>
<th scope="col" rowspan="2">Co-Ordinator</th>
<th scope="col" colspan="6">Coursework Number</th>
<th scope="col" rowspan="2">Contribution</th>
<th scope="col" colspan="6">Edit</th>
<th scope="col" rowspan="2">Upload</th>
<th scope="col" colspan="6">Manage Grades</th>
</tr>

</table>

添加.php

$display_query = "SELECT CRN, Title, Co-Ordinator, CourseworkNumber, Contribution FROM Modules";
$displayresult = mysqli_query($con, $display_query);

$num = mysql_numrows($displayresult);

mysqli_close($con);

header("Location: ../views/M.html");

我是 html 和 php 新手,不确定如何将其链接到 html

最佳答案

您可以通过多种方式做到这一点。牛在中国店的方法是这样的:

<thead>    
<tr>
<th scope="col" colspan="2">CRN</th>
<th scope="col" colspan="6">Title</th>
<th scope="col" rowspan="2">Co-Ordinator</th>
<th scope="col" colspan="6">Coursework Number</th>
<th scope="col" rowspan="2">Contribution</th>
<th scope="col" colspan="6">Edit</th>
<th scope="col" rowspan="2">Upload</th>
<th scope="col" colspan="6">Manage Grades</th>
</tr>
<?php
$display_query = "SELECT CRN, Title, Co-Ordinator, CourseworkNumber, Contribution FROM Modules";
$displayresult = mysqli_query($con, $display_query);

while($row = mysqli_fetch_assoc($display_query)) { // loop through the returned rows
// output each elemment
echo '<tr>';
echo '<td>' . $row['CRN'] . '</td>';
// other column items in the same fashion
echo '</tr>';
}

mysqli_close($con);

?>
</table>

关于javascript - 使用 html 表显示 MySql 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28417138/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com