我有以下问题, 我有一个包含以下列的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 : ?>
答案 0 :(得分:0)
使用以下代码: (根据您的需要改变: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>";
?>
如果您有更多问题或不起作用,请告诉我,我会尽力帮助。