gpt4 book ai didi

php数据库在网页中显示

转载 作者:行者123 更新时间:2023-11-28 07:39:22 24 4
gpt4 key购买 nike

如何将 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/

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