gpt4 book ai didi

php html点击查看按钮时只返回一组数据记录

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

我需要我的系统仅显示用户点击的一组“分钟”,而不是当前用户参与的每组分钟。

当我单击“图像”查看一组分钟时,它会打印出用户参与的每组分钟,我需要它仅打印出来并能够编辑一组特定的分钟...编辑功能可以工作,但我只需要它打印出用户点击的内容,而不是每组。请任何人都可以帮忙解决这个问题,我花了一整天,不明白如何让它工作。

下面是在 分钟.php 页面中显示 php 和查询的代码,当您单击“查看”图像时,它会将您带到“viewstudentmonths.php”页面,我只希望它打印出分钟您点击的不是每组。

<?php

session_start();
if (!(isset($_SESSION["sess_username"]))) header ("Location: index.php");
$currentUser=$_SESSION["sess_username"];


$dbQuery = $db->prepare("select * from minute where '$currentUser'=B_number ");
$dbQuery->execute();

$numMinutes = $dbQuery->rowCount();

echo "<p>There are $numMinutes sets of minutes in the system</p>";

$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$ID = $dbRow['ID'];
$B_number = $dbRow['B_number'];
$Date = $dbRow['Date'];
$Time = $dbRow['Time'];
$Discussion = $dbRow['Discussion'];
$Actions = $dbRow['Actions'];
$Dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$Status = $dbRow['Status'];
$E_number = $dbRow['E_number'];
$Supervisor_comments = $dbRow['Supervisor_comments'];


if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;

if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$ID) {
echo "<tr class='$rowClass '>
<form style='display:inline' method='post' action='minutes.php'>
<input type='hidden' name='editCommitID' value='$ID'>
<td><input type='varchar' name='editB_number' value='$B_number'></td>
<td><input type='date' name='editDate' value='$Date'></td>
<td><input type='time' name='editTime' value='$Time'></td>
<td><input type='text' name='editDiscussion' value='$Discussion'></td>
<td><input type='text' name='editActions' value='$Actions'> </td>
<td><input type='date' name='editDateofnextmeeting' value='$Dateofnextmeeting'></td>
<td><input type='enum' name='editStatus' value='$Status'> </td>
<td><input type='varchar' name='editE_number' value='$E_number'></td>
<td><input type='text' name='editSupervisor_comments' value='$Supervisor_comments'></td>
<td colspan='2'><input type='image' src='edit.png'>
</form>
</tr>";
} else {

echo "<tr class='$rowClass'><td>$B_number</td><td>$Date</td> <td>$Time</td><td>$Discussion</td><td>$Actions</td><td>$Dateofnextmeeting</td> <td>$Status</td><td>$E_number</td><td>$Supervisor_comments</td>
echo "<tr class='$rowClass'><td>$B_number</td><td>$Date</td><td>$Time</td><td>$Discussion</td><td>$Actions</td><td>$Dateofnextmeeting</td><td>$Status</td><td>$E_number</td><td>$Supervisor_comments</td>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editMinute_ID' value='$ID'>
<input type='image' src='edit.png' style='padding-top:7px'>
</form></td>
<td class='operation'>
<form class='display:inline' method='post' action='minutes.php'
onsubmit='return confirm(\"Are you sure?\")'>
<input type='hidden' name='deleteMinuteID' value='$ID'>
<input type='image' src='delete.png' style='padding-top:7px'>
</form></td>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'
onsubmit='viewstudentminutes.php'>
<input type='image' src='view.png' style='padding-top:7px'>

</form></td>
</tr>";
}
}


?>

下面是尝试编辑分钟集时“viewstudentmonths.php”的代码

<h2>Minutes</h2>
<table class="table table-condensed">
<?php


$dbQuery= $db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $_POST['Minute_ID']);
$dbQuery->execute();


$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$ID = $dbRow['ID'];
$B_number = $dbRow['B_number'];
$Date = $dbRow['Date'];
$Time = $dbRow['Time'];
$Discussion = $dbRow['Discussion'];
$Actions = $dbRow['Actions'];
$Dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$Status = $dbRow['Status'];
$E_number = $dbRow['E_number'];
$Supervisor_comments = $dbRow['Supervisor_comments'];


if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;

if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$id) {
echo "<tr class='$rowClass'>
<form style='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editCommitID' value='$ID'>
<tr><td colspan='2'><input type='image' src='edit.png'> </tr>
<tr><th>BNumber</th><td><input type='varchar' name='editB_number' value='$B_number'></td></tr>
<tr><th>Date</th><td><input type='date' name='editDate' value='$Date'></td></tr>
<tr><th>Time</th><td><input type='time' name='editTime' value='$Time'></td></tr>
<tr><th>Discussion</th><td><input type='text' name='editDiscussion' value='$Discussion'></td></tr>
<tr><th>Actions</th><td><input type='text' name='editActions' value='$Actions'></td></tr>
<tr><th>Date of Next Meeting</th><td><input type='date' name='editDateofnextmeeting' value='$Dateofnextmeeting'></td></tr>
<tr><th>Status</th><td><input type='enum' name='editStatus' value='$Status'></td></tr>
<tr><th>E Number</th><td><input type='varchar' name='editE_number' value='$E_number'></td></tr>
<tr><th>Supervisor Comments</th><td><input type='text' name='editSupervisor_comments' value='$Supervisor_comments'></td></tr>

</form>
</tr>";
} else {
echo "<tr class='$rowClass'>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editMinute_ID' value='$ID'>
<input type='image' src='edit.png' style='padding-top:7px'>
</form></td>
<tr><th>BNumber</th><td>$B_number</td></tr>
<tr><th>Date</th><td>$Date</td></tr>
<tr><th>Time</th><td>$Time</td></tr>
<tr><th>Discussion</th><td>$Discussion</td></tr>
<tr><th>Actions</th><td>$Actions</td></tr>
<tr><th>Date of Next Meeting</th><td>$Dateofnextmeeting</td></tr>
<tr><th>Status</th><td>$Status</td></tr>
<tr><th>E Number</th><td>$E_number</td></tr>
<tr><th>Supervisor Comments</th><td>$Supervisor_comments</td></tr>
</tr>";
}
}

?>
</table>

数据库中的分钟表包含以下字段...

1   ID   Primary    int(10)             AUTO_INCREMENT  
2 B_number varchar(15) latin1_swedish_ci
3 Date date
4 Time time
5 Discussion text latin1_swedish_ci
6 Actions text latin1_swedish_ci
7 Dateofnextmeeting date
8 Status enum('Submitted', 'Approved', 'Rejected', '') latin1_swedish_ci
9 Supervisor_comments text latin1_swedish_ci
10 E_number varchar(15) latin1_swedish_ci

请帮忙:(

最佳答案

有一些变量我不确定它们是什么 - 更新您的问题以包括 $currentUser这会有帮助。

也就是说,问题可能出在您的 SQL 语句中:

$db->prepare("select * from minute where '$currentUser'=B_number ");

您正在选择位置 $currentUser等于B_number 。但在您的数据库模式中,您显示 B_number是一列。

我会尝试这个 SQL 语句:

$db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $yourIDVariable );

编辑

您的viewstudentminutes.php将迭代 SQL 查询中返回的每条记录。您需要唯一标识您的Minute记录以仅在您的 viewstudentminutes.php 上显示一个页。您可以通过单击 <img> 访问此页面标签。但你永远不会发送 Minute 的数据您想要的对象通过此表格。您可以通过以下方式添加:

<form class='display:inline' method='post' action='viewstudentminutes.php' onsubmit='viewstudentminutes.php'>
<input type='image' src='view.png' style='padding-top:7px'>
<input type='hidden' name='minute_id' value='" . $ID . "'>
</form>

然后在您的 viewstudentminutes.php 上访问此内容如

$db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $_POST['minute_id']);

关于php html点击查看按钮时只返回一组数据记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29221851/

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