在我的页面上,我有一个表格(来自MySQL的内容)和一个页脚(使用require_once())。
问题是,即使"require_once("footer.php");“代码行在我的表显示代码之后,页脚也显示在我的表的上方。
下面是我的代码:
$table='mytable';
$result = mysql_query("SELECT * FROM {$table}");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
//echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
?>
<?
require_once("footer.php");
?>谢谢!
发布于 2012-03-14 09:00:15
在构建表的循环之后,您不会关闭table标记。
echo "</table>";将其放在while循环之后。
发布于 2012-03-14 09:00:38
我认为您需要关闭table标记:
mysql_free_result($result);
echo "</table>"
require_once("footer.php");
?>发布于 2012-03-14 09:00:41
确保关闭</table>标记。
另外,这可能是CSS的一个问题。
https://stackoverflow.com/questions/9694508
复制相似问题