我的一个网页在 MySQL_* 函数下具有完美的格式,当我将旧函数转换为 PDO 时突然变得混乱。问题是我的版权栏现在浮动在我的 MySQL 数据表上方,而它应该在页面底部。我不确定为什么会这样。任何帮助表示赞赏!
这是我认为可能是问题的文件部分:
<div id="content" style="float:center;background-image:url('http://tinyurl.com/bds4u2j');">
<ul class="menu">
<li>
<?php
if(!isset($_COOKIE['username'])){
echo "Welcome, guest!";
}else{
echo "Welcome, " . $_COOKIE['username'];
}
?>
</li>
<li><br></li>
<li><a class="item" href="index.html">Home</a></li>
<li><a class="item" href="classes.html">Classes</a></li>
<li><a class="item" href="contact.html">Contact</a></li>
<?php
if(!isset($_COOKIE['username'])){
echo '<li><a class="item" href="login.html">Login</a></li>';
}else{
echo '<li><a class="item" href="upload.html">Upload</a></li>';
echo '<li><a class="item" href="password_protect.php?logout=1">Logout</a></li>';
}
?>
</ul>
<center><h1>Mr. Stanford's first period</h1></center>
<br>
<center><h3>Your class files are available for download below</h3></center>
<br>
<br>
<center>
<?php
echo "<table border='1'>
<tr>
<th>Filename</th>
<th>Description</th>
<th>Download</th>";
IF(isset($_COOKIE["username"]))
{
echo "<th>Delete</th>","</tr>";
}
ELSE
{
echo "</tr>";
}
try{
$dbh = new PDO('mysql:host=$host;port=$port;dbname=$dbname','$username','$password');
foreach($dbh->query('SELECT * from period1') as $row) {
echo "<tr>";
echo "<td>" . $row['Filename'] . "</td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td><a href = ". $row['File'] ." ><button>Download</button></a></td>";
IF(isset($_COOKIE["username"]))
{
echo "<td><a href = 'deletefile.php?$s_id=". $row['s_id'] ."'><button>Delete</button></a></td>","</tr>";
}
ELSE
{
echo "</tr>";
}
echo "</table>";
}
$dbh=null;
} catch (PDOException $e) {
print "<br>ERROR: " . $e->getMessage() . "<br/>";
die();
}
$dbh=null;
?>
</center>
<br>
<br>
<br>
</div>
<div id="footer" style="background-color:#99FF33;clear:both;text-align:center;">
Copyright © David Schilpp 2013, All Rights Reserved
</div>
再次感谢任何可以帮助我调试此问题的人!