这是我的代码
<?php
$conn=mysqli_connect("localhost","root","","database");
$accomodation_query="SELECT * FROM accomodations";
$accomodation_result=mysqli_query($conn,$accomodation_query);
?>
<?php
while($accomodation_row=$accomodation_result->fetch_assoc())
{
$accomodation_id=$accomodation_row['accomodation_id'];
$accomodation_name=$accomodation_row['accomodation_name'];
$accomodation_type_id=$accomodation_row['accomodation_type_id'];
$accomodation_image_url=$accomodation_row['accomodation_image_url'];
$accomodation_description=$accomodation_row['accomodation_description'];
$accomodation_open=$accomodation_row['accomodation_open'];
$accomodation_address=$accomodation_row['accomodation_address'];
$accomodation_city=$accomodation_row['accomodation_city'];
$accomodation_country=$accomodation_row['accomodation_country'];
$accomodation_contact=$accomodation_row['accomodation_contact'];
$accomodation_email=$accomodation_row['accomodation_email'];
$accomodation_website=$accomodation_row['accomodation_website'];
$accomodation_lat=$accomodation_row['accomodation_lat'];
$accomodation_long=$accomodation_row['accomodation_long'];
$insert_time=$accomodation_row['insert_time'];
?>
<html><table rules="all" border="1"><tr><td><?php echo $accomodation_id; ?></td><td><?php echo $accomodation_name; ?></td><td><?php echo $accomodation_type_id; ?></td><td><?php echo $accomodation_image_url; ?></td><td><?php echo $accomodation_description; ?></td><td><?php echo $accomodation_open; ?></td><td><?php echo $accomodation_address; ?></td><td><?php echo $accomodation_city; ?></td><td><?php echo $accomodation_country; ?></td><td><?php echo $accomodation_contact; ?></td><td><?php echo $accomodation_email; ?></td><td><?php echo $accomodation_website; ?></td><td><?php echo $accomodation_lat; ?></td><td><?php echo $accomodation_long; ?></td><td><?php echo $insert_time; ?></td></tr></table></html>
<?php
}
?>
我的输出确定输出中的多行 但问题是
table =&gt;每行的长度与下一行的长度和高度不同
答案 0 :(得分:0)
使用最小高度 css中的min-width并解决了这个问题,谢谢
答案 1 :(得分:0)
输出无效的一些内容:多个html
代码,缺少head
和body
。每个行/列具有不同大小的原因是因为您生成&#34;生成&#34;适用于while
- 循环中每次迭代的新表。您真正想要做的是在循环之前打开html
和table
,并为每次迭代打印一个新的tr
。
<?php
$conn=mysqli_connect("localhost","root","","database");
$accomodation_query="SELECT * FROM accomodations";
$accomodation_result=mysqli_query($conn,$accomodation_query);
?>
<html>
<head></head>
<body>
<table rules="all">
<?php
while($accomodation_row=$accomodation_result->fetch_assoc())
{
$accomodation_id=$accomodation_row['accomodation_id'];
[...]
?>
<tr>
<td><?php echo $accomodation_id; ?></td>
<td><?php echo $accomodation_name; ?></td>
<td><?php echo $accomodation_type_id; ?></td>
[...]
</tr>
<?php } ?>
</table>
</html>