我有以下php MySQL查询代码,并希望在表单中的表格中显示结果。
<?php
$query = "SELECT * FROM persons order by date_entered DESC LIMIT 5";
$response = mysqli_query($con, $query);
if($response){
echo '<div id="frm"> <h2> Last 5 candidates entered </h2> <table align="left">
<tr>
<td align="left"><b>First Name</b></td>
<td align="left"><b>Email</b></td>
<td align="left"><b>Sex</b></td>
<td align="left"><b>City</b></td>
<td align="left"><b>Phone Number</b></td>
<td align="left"><b>Education</b></td>
<td align="left"><b>Salary</b></td>
</tr>';
while($row = mysqli_fetch_array($response)){
echo '<tr>
<td align="left">' . '<a href="person.php?id=' . $row["person_id"] . '">' . $row["first_name"] . " " .$row['last_name'] . '</a>' . '</td>
<td align="left">' . $row['email'] . '</td>
<td align="left">' . $row['sex'] . '</td>
<td align="left">' . $row['city'] . '</td>
<td align="left">' . $row['phone'] . '</td>
<td align="left">' . $row['education'] . '</td>
<td align="left">' . $row['salary'] . '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo "Couldn't issue database query<br />";
echo mysqli_error($con);
}
mysqli_close($con);
?>
表单以CSS样式定义,高度设置为auto,但表单尺寸不会延伸到结果的长度,只有160px然后停止,其余的查询结果显示在正文中。
#frm {
align: center;
font-family: "verdana";
font-size: 13px;
border: solid gray 1px;
width: 700px;
height: auto;
border-radius: 2px;
margin-left: auto;
margin-right: auto;
background: white;
padding: 50px;
}
form not extending to the length of results
我显而易见的问题是,如何使表格延伸到结果的长度?
谢谢!
答案 0 :(得分:0)
尝试浮动#frm元素或添加:
display:table;
到它。