桌子周围的PHP边框

时间:2015-05-30 13:58:44

标签: html css

我有一个PHP脚本,输出是2行数据。是否可以在PHP中添加一个表及其组件(tr,td)的边框?我想在样式元素中添加CSS边框。

这是我的代码:

<!doctype html>
<html>
<head>
<style>
td {
border-style: 1px solid black;
}

</style>
<meta charset="utf-8">
<title>oef2</title>
</head>
<body>

<?php
$host = "localhost";
$user = "*******";
$password = "*******";
$database = "elektrowinkel";

$link = mysqli_connect($host, $user, $password) or die("Er kan geen connectie gelegd worden met $host");

mysqli_select_db($link, $database) or die("databank $database niet beschikbaar");

$query = "SELECT * FROM stock_magazijnen";

$result = mysqli_query($link, $query) or die("Er is een fout opgetreden bij het uitvoeren van de query: \"$query\"");

$aantalRecords = mysqli_num_rows($result);

echo("<table><tr><th>Magazijn_ID</th><th>Product_ID</th><th>Aantal</th></tr>");

while($rij = mysqli_fetch_array($result))
{
    echo("<tr>
                <td>".$rij['Magazijn_ID']."</td>
                <td>".$rij['Product_ID']."</td>
                <td>".$rij['Aantal']."</td>
        </tr> ");
}
echo("</table>");

mysqli_close($link);

?>

2 个答案:

答案 0 :(得分:0)

<table style="border: 10px solid black">.....</table>

答案 1 :(得分:0)

如果您想让<td>只有边框,请执行(将边框样式更改为边框时):

<style>
td {
border: 1px solid black;
}
</style>

如果您希望整个表格和<td>都有边框,请在声明中添加table

<style>
table, td {
border: 1px solid black;
}
</style>

如果您只需要围绕桌子的边框而不是<td>

<style>
table {
border: 1px solid black;
}
</style>