0

我有以下代码:

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

谁能帮我解决这个问题?

4

1 回答 1

0

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

于 2013-08-30T10:00:44.323 回答