• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

php abschnitt wird nicht von css beeinflusst

richter

Neues Mitglied
Code:
<div id="phpcode">
<table>
    <thead>
        <tr>
            <td>Titel</td>
            <td>Interpret</td>
            <td>Album</td>
            <td>Size</td>
        </tr>
    </thead>
 
        <?php
            $connection = mysqli_connect("localhost", "root", "blablabla");
            mysqli_select_db($connection, "databasename");
            $output = mysqli_query($connection, "select * from music");

            while ($zeile = mysqli_fetch_array($output)) {
        ?>
                <colgroup>
                    <col width="300px" />
                </colgroup>
        <?php              print("<td>" . $zeile["title"] . "</td>");
                           print("<td>" . $zeile["interpreter"] . "</td>");
                            print("<td>" . $zeile["album"] . "</td>");
                             print("<td>" . $zeile["size"] . "</td><br />");
            }
            mysqli_close($connection);    
        ?>
</table>
</div>



Code:
#phpcode {
    position: fixed;
    left: 200px;
    top: 80px;
    background-color:#FFFFCC;
    overflow: scroll;
    width: 1080px;
    height: 300px;
}


problem.jpg

wie mach ich, dass die vom php-code ausgespuckte tabelle in der mitte des hellgelben bereichs steht?

mit freundlichen grüssen
 
PHP hat rein gar nichts mit Darstellung zu tun. Dir geht es darum den von PHP erzeugten HTML-Code zu zentrieren. Folglich müsstest Du die Tabelle zentrieren. Also im CSS ergänzen:

Code:
#phpcode table {
 margin: 0 auto;
 width: 300px;
}
 
Zurück
Oben