gpt4 book ai didi

mysql - 将日期从mysql插入到表html中

转载 作者:行者123 更新时间:2023-11-30 01:20:02 25 4
gpt4 key购买 nike

我有以下问题,我有一个 mysql 表,其中包含以下列,

-name
-address
-zipcode
-etc.

我的 php 代码中有一个像这样的表:

<table class="listing" cellpadding="0" cellspacing="0">
<tr>
<th>Company name</th>
<th>Adress</th>
<th>Zipcode</th>
<th>more</th>
<th>more</th>

<th>more</th>
<th>more</th>
<th>more</th>
</tr>
</table>

我想要的是,当有人创建一家公司时,它将显示一行包含来自 mysql 的数据,如下所示:

公司           地址          邮政编码
1                         1                     1
2                         2                     2

有人可以帮助我吗?

编辑:

一些额外的代码:

    <div id="center-column">
<div class="select-bar">
Bedrijven:
</div>
<div class="table">
<table class="listing" cellpadding="0" cellspacing="0">
<tr>
<th>Company name</th>
<th>Adress</th>
<th>Zipcode</th>
<th>more</th>
<th>more</th>

<th>more</th>
<th>more</th>
<th>more</th>
</tr>
</table>
</div>
<div class="table">
</div>
</div>
<div id="right-column">
<strong class="h">Info</strong>
<div class="box"><strong>Gebruikersnaam:</strong> <?php echo $naam ?><br />
</div>
</div>
</div>
<div id="footer"></div>
</div>
</body>
</html>
<?php else : ?>

最佳答案

使用以下代码:(更改为您的需要:localhost、USERNAME、PASSWORD、DATABASE_NAME、TABLE_NAME、TABLE_ROW)

$con = mysqli_connect('localhost','USERNAME','PASSWORD','DATABASE_NAME');
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$sql = "USE DATABASE_NAME";
$sql = "SELECT * FROM TABLE_NAME";

$result = mysqli_query($con,$sql)
or die("Error: " . mysqli_error($con));

echo "<table border='0'>";
while ($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . 'Company: ' . "<b>" . $row['TABLE_ROW'] . "</b>" . ' | Address: ' . "<b>" . $row ['TABLE_ROW'] . "</b>" . ' | Zipcode: ' . "<b>" . $row ['TABLE_ROW'] . "</b>" . "</td>";
echo "</tr>";
}
echo "</table>";
?>

如果您有更多问题或不起作用,请告诉我,我会尽力提供帮助。

关于mysql - 将日期从mysql插入到表html中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18652343/

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