gpt4 book ai didi

PHP/HTML 表单显示

转载 作者:太空宇宙 更新时间:2023-11-04 16:05:16 24 4
gpt4 key购买 nike

有人能告诉我我做错了什么吗?代码运行良好,但输出的结果很奇怪。它给了我一个额外的专栏。

<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$serverName = "server\sqlexpress";
$connectionInfo = array("Database"=>"mine");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn === FALSE){
die( print_r( sqlsrv_errors(), true));
}

$sql = 'SELECT id, name, age FROM names';
$records = sqlsrv_query($conn, $sql);

?>

<html>
<head>
<meta charset="UTF-8">
<title>Heath Data</title>
</head>
<body>
<table width="600" border="1" cellspacing="1" cellpadding="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Age</th>
</tr>


<?php
while ($employee = sqlsrv_fetch_array($records, SQLSRV_FETCH_ASSOC)){
echo "<tr>";
echo "<td>".$employee['id']."<td>";
echo "<td>".$employee['name']."<td>";
echo "<td>".$employee['age']."<td>";
echo "<tr>";

}
?>

</table>
</body>

结果如下: enter image description here

为什么要多出一列?

最佳答案

只需要终止标签

echo "<tr>";
echo "<td>".$employee['id']."</td>";
echo "<td>".$employee['name']."</td>";
echo "<td>".$employee['age']."</td>";
echo "</tr>";

关于PHP/HTML 表单显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38625940/

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