表向下移动自己

时间:2013-08-30 09:55:23

标签: php html css twitter-bootstrap

我有以下代码:

    <?php session_start(); ?>
<!DOCTYPE HTML>
<html>
<head>
<title> Admin Login </title>
<link rel="stylesheet" href="../bootstrap.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<style>
    body {

        padding:40px;
    }
</style>
</head>
    <body>
    <div class="container">
<?php

if(!isset($_SESSION['AdminAc'])) {
;
if(isset($_POST['login'])) {

    require("../src/config.php");

    if($AdminUsername != $_POST['username']) {

        $error = "Incorrect Username";
    } elseif($AdminPassword != $_POST['password']) {

        $error = "Incorrect Password";
    } elseif($AdminPassword != $_POST['password'] && $AdminUsername != $_POST['Username']) {

        $error = "Incorrect Cridentials";

    } else {

        $_SESSION['AdminAc'] = true;
        header("Location: ".$_SERVER['PHP_SELF'].""); exit();

            }

}

?>
    <br />
    <h4> Admin Login </h4>
    <?php if(isset($error)) { ?> <div class="alert alert-danger" style="width:45%;"> <?php echo $error; ?> </div> <?php } ?>
    <form action="" method="POST">
    <input type="text" name="username" placeholder="Admin Username"/>
    <input type="password" name="password" placeholder="Admin Password"/> <br />
    <input type="submit" name="login" class="btn btn-success" value="Continue"/>
    </form>
    </body>
    </html>

    <?php
} else {
    require('../src/config.php');
?>
<div class="container">
<div style="float:left; margin:10px;">
Hello, <strong><?php echo ucfirst($AdminUsername); ?></strong>
| <a href="?logout"> Logout </a>
<br /><br />
<ul class="nav nav-pills nav-stacked">
 <li> <a href="change_password.php"> <i class="icon-unlock-alt"></i> Change Password </a> </li>
 <li> <a href="add_user.php"> <i class="icon-user"></i> Add User </a> </li>
</ul>
</div>
<div class="well" style="text-align:center; margin: 0 auto; overflow:auto;">
<h3> Admin Panel </h3>
<hr />
<table align=center class="table">
<?php
    $q = $con->query("SELECT * FROM users");
    while($qq = $q->fetch_object()) {
        echo "<tr> <td align=left style='padding-right:10px;''> ".$qq->username."</td> <td align=right> <a href='?delete=".$qq->ID."'> Delete </a> </td> </tr> <br />";
    }
    if($q->num_rows < 1) {
        echo "<div style='text-align:center;'> No users exist in the database</div>";
    }
?>  
</table>
</div>
<?php
if(isset($_GET['delete'])) {
    $ID = $_GET['delete'];
    $con->query("DELETE FROM users WHERE ID='$ID'");
    header("Location: ".$_SERVER['PHP_SELF'].""); exit();
}
if(isset($_GET['logout'])) {
    session_destroy();
    header("Location: ".$_SERVER['PHP_SELF'].""); exit();
}
}

我的问题特别是以下几行代码:

 <div class="well" style="text-align:center; margin: 0 auto; overflow:auto;">
    <h3> Admin Panel </h3>
    <hr />
    <table align=center class="table">
    <?php
        $q = $con->query("SELECT * FROM users");
        while($qq = $q->fetch_object()) {
            echo "<tr> <td align=left style='padding-right:10px;''> ".$qq->username."</td> <td align=right> <a href='?delete=".$qq->ID."'> Delete </a> </td> </tr> <br />";
        }
        if($q->num_rows < 1) {
            echo "<div style='text-align:center;'> No users exist in the database</div>";
        }
    ?>  
    </table>
    </div>

在每个新的表格条目中,该表格沿着页面向下移动,与我在http://prntscr.com/1o9zbl

这个屏幕截图中的顶部留下了巨大差距

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

为什么<br/>语句结尾处有echo。删除它应该可以解决您的问题。