简体   繁体   中英

PDO Messed Up My CSS / HTML Layout

One of my webpages that had perfect format under MySQL_* functions, suddenly got mixed up when I translated the old functions to PDO. The problem is that my Copyright bar is now floating above my table of MySQL data, while it should be at the bottom of the page. I'm not sure why it's happening. Any help is appreciated!


This is the portion of the file that I believe may be the problem:

<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>

Again, thank you to anybody who can help me debug this problem!

I guessed that your table was not closed. see comments on question.

When you are facing this kind of problem (broken html), you should first analyse the html generated.

You can right-click on page and select View page source .

You can use tools freely available too.

As always, StackOverflow is great place to find answer and new stuff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM