php - 如何用结果填充 HTML 表格并过滤它们
问题描述
到目前为止,这是我的代码。我试图通过 html 在表中显示我的数据库的一个表。然后我希望能够使用关键字过滤这些结果,但是,此时结果甚至没有显示,我不确定为什么?所有代码目前都在一个文件中,calendar.php
<?php
session_start();
if(isset($_POST['search'])) {
}else {
$query = "SELECT * FROM knockout"; //selecting all results in table and filtering
$search = filterTable($query);
}
function filterTable($query){
include_once "action/dbcon.php";
$filter = mysqli_query($conn, $query);
return $filter;
}
?>
<form>
<input type=text name="valueToSearch" placeholder="Search">
<input type=submit name="search" value="filter">
<table>
<tr>
<th>Id:</th>
<th>Team 1:</th>
<th>Team 2:</th>
<th>Date::</th>
</tr>
</table>
<?php while($row = mysqli_fetch_array($search)); ?>
<tr>
<td><?php echo $row['knockout_id']; ?></td>
<td><?php echo $row['knockout_team1']; ?></td>
<td><?php echo $row['knockout_team2']; ?></td>
<td><?php echo $row['knockout_date']; ?></td>
</tr>
<?php endwhile;?>
</form>
解决方案
推荐阅读
- php - PHP脚本在达到某些输出限制后死亡
- apache - Apache:如何通过将 IP 地址列入白名单来限制对文件夹的访问?
- android - 应用程序在后台时调用Android Activity onStart?
- kotlin-coroutines - koltin,与直接使用 CoroutineScope 并从 CoroutineScope 派生类有什么区别
- android - 您可以使用 Android Enterprise 发送自定义命令吗?
- java - flink 运行超过 12 小时导致机器 CPU 负载增加的原因
- sql - TSQL Pivot Sum 函数结果不正确
- tensorflow - 如何手动计算 tensorflow 中 conv3d 的反向传播?
- python - 检测命令是否修改了 Python 脚本中目录中的任何文件
- docker - 使用现有卷运行 docker