Php 可以在表中运行两个单独的查询吗?
是否可以在一个表中运行两个查询?一个是表本身,第二个是模式,如果用户的请求状态已被批准,则第二个查询就像一个检查器 “我的表的代码,Php 可以在表中运行两个单独的查询吗?,php,mysql,Php,Mysql,是否可以在一个表中运行两个查询?一个是表本身,第二个是模式,如果用户的请求状态已被批准,则第二个查询就像一个检查器 “我的表的代码,是选择表中的所有内容并在表中打印出来的查询。” <table class="table table-striped table-hover table-condense" id="tbl_manageStudents"> <thead>
是选择表中的所有内容并在表中打印出来的查询。”
<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>
包括_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 {
}
}
}
?>
但问题是,当我在模式中包含第二个查询时,
表格只显示1行,尽管我有3行。
如有任何建议或帮助,我们将不胜感激。您可以使用for loop
<?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
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';
}
}
?>