如何将 css 应用于 $row["name"]
并将其显示在表格中?
这是我的代码:
<div class="maincontent1">
<?php
$link = mysqli_connect("localhost","root","","webpage2") or die("Error " . mysqli_error($link));
$sql = "SELECT id, name, description1 FROM table1";
$result = $link->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
?>
<div class="title-style1">
<?php
echo $row["name"];
?>
</div>
<?php
echo $row["description1"];
}
$link->close();
}
?>
最佳答案
我不清楚你所说的关于 css 的内容,但是如果你希望你的数据打印在表格中,那么你可以这样做
<table>
<tr>
<th>
Name
</th>
<th>
Description
</th>
</tr>
<?php
$link = mysqli_connect("localhost","root","","webpage2") or die("Error " . mysqli_error($link));
$sql = "SELECT id, name, description1 FROM table1";
$result = $link->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
?>
<tr>
<div class="title-style1">
<td> <?php
echo $row["name"];
?>
</td>
<td>
<?php
echo $row["description1"];
?>
</td>
</div>
</tr>
<?php
}
$link->close();
}
?>
</table>
关于php数据库在网页中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31041355/