我正在艰难地为我的身体出现一个标题

时间:2014-01-02 01:52:28

标签: html css

我正在尝试将标题显示在此页面的正文中。好吧,由于某种原因,当我使用中心标签时,标题不显示,我无法弄清楚原因。有人能告诉我我的中心标签出了什么问题吗?

<!DOCTYPE HTML>
<html>
<head>
    <title><?php echo'giggity'?></title>
</head>
<body>
    <?php 
    $Title="The Title of my page";
    ?>
    <center><?php echo $Title;?></center>
    <?php
        $con = mysqli_connect('localhost', 'username', 'password','Employees');
        if (mysqli_connect_errno())
    {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
        // $db = mysqli_select_db($con,'Employees');
        $sql = "select * from Employ";
        $query = mysqli_query($con,$sql);


        echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 0; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>
            <tr>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Meetings_Today</th>
            <th>Sales</th>
            <th>Comments</th>
            </tr>";

//now read and display the entire row of a table one by one looping through it.
//to loop we are using While condition here
 while( $row = mysqli_fetch_array($query) )
{
    echo "<tr><td>". $row['Firstname']. "</td>";
    echo "<td>". $row['Lastname']. "</td>";
    echo "<td>". $row['Meetings']. "</td>";
    echo "<td>". $row['Sales']. "</td>";
    echo "<td>". $row['Comments']. "</td></tr>";
}

        echo "</table>";
 mysqli_close($con);

?>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

以下代码适用于我(请参阅http://www.floris.us/SO/title.php

<!DOCTYPE HTML>
<html>
<head>
    <title><?php echo'giggity'?></title>
</head>
<body>
    <?php 
    $Title="The Title of my page";
    ?>
    <center><?php echo $Title;?></center>
    </body>
    </html>

这正是您粘贴的代码(相同的空格等),但在打印标题后关闭正文和html标记。

我建议你从这开始,然后添加代码“直到它中断”。

好的 - 我自己添加了代码。你布置桌子的方式,它一直到页面的顶部,因此“坐在标题的顶部”。将top更改为为标题留出空间的内容 - 或将标题放在表格中......

可能的解决方案:

echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 50; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>

我把它放在http://www.floris.us/SO/title2.php

源代码:

<!DOCTYPE HTML>
<html>
<head>
    <title><?php echo'giggity'?></title>
</head>
<body>
    <?php 
    $Title="The Title of my page";
    ?>
    <center><?php echo $Title;?></center>
    <?php
        echo "<table border ='1' style='height:90%;width:90%; position: absolute; top: 50; bottom: 0; left: 0; right: 0;border:1px solid' BGCOLOR='00FF00'>
            <tr>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Meetings_Today</th>
            <th>Sales</th>
            <th>Comments</th>
            </tr>";

// replace db access with a single line of text:

    echo "<tr><td>". "John". "</td>";
    echo "<td>". "Smith". "</td>";
    echo "<td>". "Pocahontas". "</td>";
    echo "<td>". "Firewater". "</td>";
    echo "<td>". "English". "</td></tr>";

    echo "</table>";

?>
</body>
</html>