是否有可能在回声中设计一个元素

时间:2017-07-16 16:41:40

标签: php html css mysqli

我按照教程制作一个分页表,我想做的就是尽可能..设计链接,(123)在蓝色背景的顶部,如添加填充,因为它们太局促,颜色:白色等等,把它放在桌子下面。任何帮助和建议表示赞赏。

enter image description here

<div style="overflow-x:auto;">
        <table class="reservations-table">
        <thead>
            <th class="thFirstName">First Name</th>
            <th class="thLastName">Last Name</th>
            <th class="thEmailAddress">Email Address</th>
            <th class="thContactNumber">Contact Number</th>
            <th class="thSpeaker">Speaker</th>
            <th class="thTopic">Topic</th>
            <th class="thLocation">Location</th>
            <th class="thAudience">Audience</th>
            <th class="thCount">Count</th>
            <th class="thTime">Time</th>
            <th class="thDate">Date</th>
            <th class="thAction">Action</th>
        </thead>
    <?php

        $servername = "localhost";
        $username = "root";
        $password = "";
        $dbname = "srdatabase";

        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn->connect_error) 
        {
            die("Connection failed: " . $conn->connect_error);
        } 

        $results_per_page = 10;
        $select= "SELECT * FROM reservations";
        $result = mysqli_query($conn, $select);
        $number_of_results = mysqli_num_rows($result);

        if(!isset($_GET['page']))
        {
            $page = 1;
        }
        else
        {
            $page = $_GET['page'];
        }

        $this_page_first_result = ($page-1)*$results_per_page;

        $sql = "SELECT * FROM reservations LIMIT " . $this_page_first_result . ',' . $results_per_page;
        $result = mysqli_query($conn, $sql);

            while ($row=mysqli_fetch_array($result))
        {
            echo "<tr>
                <td>".$row['firstname']."</td>
                <td>".$row['lastname']."</td>
                <td>".$row['emailaddress']."</td>
                <td>".$row['contactnumber']."</td>
                <td>".$row['speaker']."</td>
                <td>".$row['topic']."</td>
                <td>".$row['location']."</td>
                <td>".$row['audience']."</td>
                <td>".$row['count']."</td>
                <td>".$row['time']."</td>
                <td>".$row['date']."</td>
                <td align='center'><a href='adminControl.php?epr=delete&id=".$row['id']."'>DELETE</a></td>
            </tr>";         
        }

        $number_of_pages = ceil($number_of_results/$results_per_page);

    ?>

    <center>
    <div id="paging-div">

    //paging link 123

    <?php
        for($page=1;$page<=$number_of_pages;$page++)
        {
            echo '<a href="adminControl.php?page=' . $page . '">' . $page . '</a>';
        }
    ?>

2 个答案:

答案 0 :(得分:1)

请在<tbody>之后添加<tbody>并关闭</thead>。请关闭表格标签</table>

请尝试以下

<div style="overflow-x:auto;">
    <table class="reservations-table">
    <thead>
        <th class="thFirstName">First Name</th>
        <th class="thLastName">Last Name</th>
        <th class="thEmailAddress">Email Address</th>
        <th class="thContactNumber">Contact Number</th>
        <th class="thSpeaker">Speaker</th>
        <th class="thTopic">Topic</th>
        <th class="thLocation">Location</th>
        <th class="thAudience">Audience</th>
        <th class="thCount">Count</th>
        <th class="thTime">Time</th>
        <th class="thDate">Date</th>
        <th class="thAction">Action</th>
    </thead>
    <tbody>
<?php

    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "cktest01";

    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) 
    {
        die("Connection failed: " . $conn->connect_error);
    } 

    $results_per_page = 10;
    $select= "SELECT * FROM reservations";
    $result = mysqli_query($conn, $select);
    $number_of_results = mysqli_num_rows($result);

    if(!isset($_GET['page']))
    {
        $page = 1;
    }
    else
    {
        $page = $_GET['page'];
    }

    $this_page_first_result = ($page-1)*$results_per_page;

    $sql = "SELECT * FROM reservations LIMIT " . $this_page_first_result . ',' . $results_per_page;
    $result = mysqli_query($conn, $sql);

        while ($row=mysqli_fetch_array($result))
    {
        echo "<tr>
            <td>".$row['firstname']."</td>
            <td>".$row['lastname']."</td>
            <td>".$row['emailaddress']."</td>
            <td>".$row['contactnumber']."</td>
            <td>".$row['speaker']."</td>
            <td>".$row['topic']."</td>
            <td>".$row['location']."</td>
            <td>".$row['audience']."</td>
            <td>".$row['count']."</td>
            <td>".$row['time']."</td>
            <td>".$row['date']."</td>
            <td align='center'><a href='adminControl.php?epr=delete&id=".$row['id']."'>DELETE</a></td>
        </tr>";         
    }

    $number_of_pages = ceil($number_of_results/$results_per_page);

?>
</tbody>
</table>


<div id="paging-div">

<!-- paging link 123 -->

<?php
    for($page=1;$page<=$number_of_pages;$page++)
    {
        echo '<a style="color:green" href="adminControl.php?page=' . $page . '">' . $page . '</a>';
    }
?>

   </div>
</div>

答案 1 :(得分:1)

我不确定您的详细信息,但当然您可以将CSS style属性添加到回显的HTML中。

示例(观看td标签):

echo "<tr>
            <td style='background:#fca;'>".$row['firstname']."</td>
            <td 'background:#cfb;'>".$row['lastname']."</td> 
etc.....

注意:我使用单引号作为标记style atrribute值的引号。那些不会干扰你用于回声的双引号。