php / css错误,不要将Style加载到某些对象

时间:2015-12-10 08:06:01

标签: php html css sql

我的php代码出现了一些奇怪的问题 当我尝试输出此echo "<div class='button menu' onclick=\"javascript:location.href='$baseURI'\">Menu</div>";

有时它不会加载css,即使不是 div -tags,只是简单的“菜单”字符串 它始终打印在我的表格 -tags

之前

这怎么可能?

PHP代码:

<?php
$root_dir = $_SERVER['PHP_SELF'];
echo "<link rel='stylesheet' href='style.css' type='text/css'>";
if (!isset($_GET['command'])) {
    echo "<div class='button' onclick=\"javascript:location.href='$baseURI?command=show'\">Personaldaten anzeigen</div>";
    //echo "<div class='button' onclick=\"javascript:location.href='$baseURI?command=new'\">neue Person anlegen</div>";
    //echo "<div class='button' onclick=\"javascript:location.href='$baseURI?command=work'\">Personaldaten bearbeiten</div>";
} else {
    if ($_GET['command'] == "show") {
        openSQL();
        $sqlbefehl = 'select * from kontakt';
        @mysql_query("SET NAMES 'utf8'");
        $ergebnis = @mysql_query($sqlbefehl); // SQL-Befehl an die Datenbank schicken
        $spalten  = @mysql_num_fields($ergebnis);
        echo "<table class='style'>";
        echo "<tr>";
        for ($i = 0; $i < $spalten; $i++) {
            echo "<th class='th'>" . mysql_field_name($ergebnis, $i) . "</th>";
        }
        echo "</tr>";
        while (false != ($row = mysql_fetch_row($ergebnis))) {
            echo "<tr>";
            for ($i = 0; $i < sizeof($row); $i++) {
                echo "<td>$row[$i]</td>";
            }
            echo "</tr>";
        }
        echo "</table";
    }
    echo "<div class='button menu' onclick=\"javascript:location.href='$baseURI'\">Menu</div>";
}
function openSQL()
{
    $server   = "127.0.0.1";
    $user     = "root";
    $passwort = "";
    $db       = "schule";
    $dblink   = @mysql_connect($server, $user, $passwort);
    if (!@mysql_select_db($db)) {
        echo "<br>Keine Verbindung zur Datenbank $db möglich!";
        echo "<br>" . mysql_error();
        die();
    }
}
?>

CSS-代码:

body{
    font-family: Verdana;
    color: #fff;
    background-color: #000;

}
.style{
    border-collapse: collapse;
    text-align: center;
}

.style table,.style th,.style td {
    border: 1px solid white;
}
.style td {
    overflow: hidden;
    font-size: 12px;
}
.button{
    height: 68px;
    width: 200px;
    border: 3px orange solid;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    border-radius: 5px;
    vertical-align: center;
    font-size: 24px;
    margin-top: 15px;
    background-color: #000;
}
.menu{
    height: 36px;
    width: 75px;
}
.delBtn{
    height: 36px;
    width: 95px;
}
.del{
    background-image: url(del.png);
    background-repeat: no-repeat;
    width:24px;
    height: 24px;
    background-size: 25px 25px;
}
.edit{
    background-image: url(edit.png);
    background-repeat: no-repeat;
    background-position: center;
    width:24px;
    height: 24px;
    background-size: 40px 40px;
}

1 个答案:

答案 0 :(得分:1)

所以我回答了我自己的问题。这是失踪的&#34;&gt;&#34;在收盘表 - 标签。由于我修复了缺失的字符,因此代码现在可以正常工作。

感谢您的所有努力&lt; 3