gpt4 book ai didi

php - 每条记录都有自己的表头

转载 作者:行者123 更新时间:2023-11-29 00:07:38 24 4
gpt4 key购买 nike

是否可以为每条记录而不是数据库中的所有记录设置表。我可以用 asp.net 来做,但不知道如何用 php 来做。我只需要一个样本,而不是为我完成的工作,也不需要一本书或展示如何做的链接。

<?php
require_once("../db_connect.php");
error_reporting(E_ERROR | E_PARSE);

$sql = "SELECT id, lanId, name, department, manager, request, request_description, request_comments, status, comments, compUser, compDt FROM requests WHERE status='received'";
$results = mysql_query($sql) or die(mysql_error());



echo"Received Requests";
echo "<br><br>";
echo("<table bgcolor=F2F2F2 width=1000 border='2'>");

echo("<tr><th>Id</th><th>LanID</th><th>Name</th><th>Department Location</th><th>Manager</th><th>request</th><th>request_description</th><th>request_comments</th><th>Status</th><th>Comments</th><th>Completed User</th><th>Completed Date</th><th>Update</th></tr>");
while($row = mysql_fetch_array($results)){

echo("<tr>");

echo "<td>". $row['id'] . "</td>"
."<td>" . $row['lanId'] . "</td> "
. "<td>". $row['name'] . "</td>"
. "<td>". $row['department'] . "</td>"
. "<td>" . $row['manager'] . "</td>"
. "<td>" . $row['request'] ."</td>"
. "<td>" . $row['request_description'] ."</td>"
. "<td>" . $row['request_comments'] ."</td>"
. "<td>" . $row['status'] ."</td>"
. "<td>" . $row['comments'] ."</td>"
. "<td>" . $row['compUser'] ."</td>"
. "<td>" . $row['compDt'] ."</td>"
."<td><a href='../update.php?id=" . $row['id'] . "'>Update</a></td>";



echo '</tr>';

}
echo("</table>");

?>


<html>

<head>
<meta http-equiv="refresh" content="5" >
<title>

</title>
</head>
<body background="../images/background.jpg">

</body>

</html>

最佳答案

只需将表标签放在 while 循环中

echo("<table  bgcolor=F2F2F2 width=1000 border='2'>");


while($row = mysql_fetch_array($results)){
echo("<tr><th>Id</th><th>LanID</th><th>Name</th><th>Department Location</th><th>Manager</th> <th>request</th><th>request_description</th><th>request_comments</th><th>Status</th><th>Comments</th> <th>Completed User</th><th>Completed Date</th><th>Update</th></tr>");
echo("<tr>");

echo "<td>". $row['id'] . "</td>"
."<td>" . $row['lanId'] . "</td> "
. "<td>". $row['name'] . "</td>"
. "<td>". $row['department'] . "</td>"
. "<td>" . $row['manager'] . "</td>"
. "<td>" . $row['request'] ."</td>"
. "<td>" . $row['request_description'] ."</td>"
. "<td>" . $row['request_comments'] ."</td>"
. "<td>" . $row['status'] ."</td>"
. "<td>" . $row['comments'] ."</td>"
. "<td>" . $row['compUser'] ."</td>"
. "<td>" . $row['compDt'] ."</td>"
."<td><a href='../update.php?id=" . $row['id'] . "'>Update</a></td>";



echo '</tr>';
echo("</table>");
}

关于php - 每条记录都有自己的表头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26762469/

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