如果表单提交为空,我使用会话,会话确定但不打开msg

时间:2018-01-19 10:28:05

标签: php sql

这是我的代码

    <?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;每行的长度与下一行的长度和高度不同

2 个答案:

答案 0 :(得分:0)

使用最小高度 css中的min-width并解决了这个问题,谢谢

答案 1 :(得分:0)

输出无效的一些内容:多个html代码,缺少headbody。每个行/列具有不同大小的原因是因为您生成&#34;生成&#34;适用于while - 循环中每次迭代的新表。您真正想要做的是在循环之前打开htmltable,并为每次迭代打印一个新的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>