每条记录都有自己的标题表

时间:2014-11-05 16:42:26

标签: php mysql

是否可以为每条记录设置表格而不是数据库中的所有记录。我可以用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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

只需将表格标签放在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>");
}