gpt4 book ai didi

php - 样式化 PHP 回显表

转载 作者:太空宇宙 更新时间:2023-11-03 23:08:11 26 4
gpt4 key购买 nike

我终于弄清楚了如何使用 PHP 显示我的 SQL 表,但是我很难让样式显示出来。到目前为止,这是我所拥有的,关于如何设计 echo 的任何指示?什么都没有出现。我这样做是不是设计 echo 的不正确方式?我正在尝试使用 Bootstrap CSS 设置样式。

<html>
<head>
<title>Abacus PHP SQL Server Connection</title>
</head>
<body>
<?php
$db_host = '***';
$db_user = '***'; //recommend using a lower privileged user
$db_pwd = '***';
$database = '***';
$table = '***';

$connectionInfo = array("UID" => $db_user, "PWD" => $db_pwd, "Database"=>$database);
$conn = sqlsrv_connect( $db_host, $connectionInfo);
if( !$conn )
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}

$tsql = "SELECT category, data_desc, data_source, update_cycle,ISNULL(datename(mm,last_abadata_update) + + ' ' + DATENAME(dd,last_abadata_update) + ', ' + DATENAME(yyyy, last_abadata_update),'') AS last_abadata_update, ISNULL(datename(mm,last_abadata2_update) + ' ' + DATENAME(dd,last_abadata2_update) + ', ' + DATENAME(yyyy,last_abadata2_update),'') AS last_abadata2_update FROM {$table} ORDER BY category, data_source, data_desc";
$result = sqlsrv_query( $conn, $tsql);
if (!$result) {
die("Query to show fields from table failed");
}

echo "<table >";
echo "<tr>";

// printing table headers with desired column names
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Category";
echo "</td>";
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Description";
echo "</td>";
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Source";
echo "</td>";
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Update Cycle";
echo "</td>";
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Last AbaData Update";
echo "</td>";
echo "<td style='border=1px solid black;Font-size=18;Font-Weight=bold'>";
echo "Last AbaData 2.0 Update";
echo "</td>";
echo "</tr>";

while($row = sqlsrv_fetch_array($result))
{
echo "<tr>";
echo "<td style='border=1px solid black'>";
echo $row['category'];
echo "</td>";
echo "<td style='border=1px solid black'>";
echo $row['data_desc'];
echo "</td>";
echo "<td style='border=1px solid black'>";
echo $row['data_source'];
echo "</td>";
echo "<td style='border=1px solid black'>";
echo $row['update_cycle'];
echo "</td>";
echo "<td style='border=1px solid black'>";
echo $row['last_abadata_update'];
echo "</td>";
echo "<td style='border=1px solid black'>";
echo $row['last_abadata2_update'];
echo "</td>";
echo "</tr>\n";
}
echo "</table>";

sqlsrv_free_stmt( $result);
sqlsrv_close( $conn);
?>
</body>
</html>

最佳答案

CSS 接受 : 而不是 = 所以将 style='border=1px solid black' 更改为 style='border:1px纯黑色'.

关于php - 样式化 PHP 回显表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33943544/

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