php - 是否可以在表中运行两个单独的查询?
问题描述
是否可以在一个表中运行两个查询?一个是表本身,第二个是模态的,第二个查询就像一个检查器,如果用户的请求状态已被批准。
我的表的代码,<?php includes/repositoryretriever.php; ?>
是选择表中的所有内容并在表中打印出来的查询。
<table class="table table-striped table-hover table-condense" id="tbl_manageStudents">
<thead>
<tr>
<th scope="col">Research UID</th>
<th scope="col">Research Title</th>
<th scope="col">Research Type</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
include 'includes/repositoryretriever.php';
?>
</tbody>
</table>
在表格内,如您所见,我有一个Action
操作按钮,有一个弹出模式,现在在弹出模式中,应该有一个动态按钮,用于识别用户是否已经获得管理员的批准。
我在模态中的代码。<?php includes/includes_checkRequestStatus.php ?>
是两个表的连接表
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="researchModal<?php echo
$row["ID"]; ?>">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle"><?php echo $row['research_title']; ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h2>Research Abstract:</h2>
<p>
<?php
echo $row['research_description']; ?>
</p>
<h2>Author:</h2>
<p><?php echo $row['research_author']; ?> </p>
<div class="text-center">
<?php
require_once 'includes/includes_checkRequestStatus.php';
?>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
包括_checkRequestStatus.php
<?php
include 'includes/connection_operation.php';
$sql = "SELECT tbl_requestforms.ID, tbl_requestforms.request_id, tbl_repository.research_title, tbl_repository.research_tags, tbl_students.student_name, tbl_requestforms.request_status
FROM tbl_repository
JOIN tbl_students
ON tbl_repository.research_uid = tbl_students.student_id
JOIN tbl_requestforms ON tbl_requestforms.student_id=tbl_students.student_id
WHERE tbl_repository.research_uid = tbl_students.student_id;";
$query = mysqli_query($conn, $sql);
if ($query) {
while ($row = mysqli_fetch_assoc($query)) {
if($row['request_status'] == null){
?>
<input type="submit" name="submit" id="submit" value="Delete" class="btn btn-danger"
data-toggle="modal" data-target="#deleteResearchModal<?php echo $row["ID"];?>">
<?php
}
else {
}
}
}
?>
存储库检索器.php
<?php
include 'includes/connection_operation.php';
$sql = "SELECT * FROM tbl_repository";
$query = mysqli_query($conn, $sql);
if ($query) {
while ($row = mysqli_fetch_assoc($query)) {
?>
<tr>
<th><?php echo $row['research_uid']; ?></th>
<td><?php echo $row['research_title']; ?></td>
<td><?php echo $row['research_tags']; ?></td>
<td>
<input type="submit" name="submit" id="submit" value="View" class="btn btn-info"
data-toggle="modal" data-target="#researchModal<?php echo $row["ID"]; ?>">
</td>
</tr>
<?php
include './helper/helper_researchModal.php';
}
}
?>
但问题是,当我在模态中包含我的第二个查询时,<?php includes/includes_checkRequestStatus.php ?>
该表仅显示 1 行,尽管我在那里有 3 行。任何建议或帮助将不胜感激。
解决方案
推荐阅读
- javascript - 如何将分钟、小时或天转换为秒并将其发送到 React 中的 API?
- python-3.x - 假redis中没有名为“lupa”的模块
- python - 均值浮动值的泊松分布
- c# - 如何在 C#with MySQL 查询中处理大量数据?
- excel - 搜索单元格中的更改并输出已更改单元格的地址
- azure - Windows 节点在 5 分钟后与 Azure 中的 Jenkins 主服务器断开连接
- c++ - C/C++ 错误:越界读取。查看错误的内存地址
- sql - 我在 ms 访问查询输入中遇到此错误必须包含至少一个表或查询
- java - 如何获得数字的某个小数位?
- ios - 何时必须调用 CLLocationManager requestAlwaysAuthorization?