php - css 是否可以在 echo 中设计一个元素

标签 php html css mysqli

我按照教程制作一个带有分页的表格,如果可能的话,我想做的是..在顶部的蓝色背景中设计链接(123),就像添加填充一样,因为它们太拥挤了,颜色:白色等,并将其放在 table 下方。如有任何帮助和建议,我们将不胜感激。

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>';
        }
    ?>

最佳答案

请添加<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>

关于php - css 是否可以在 echo 中设计一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45130984/

相关文章:

php - 将jQuery文件上传与表单结合到mysql

php mysql 无限循环

php - 当我尝试以编程方式将图表添加到 google 电子表格时,api v4 失败并出现关于网格 id 的 Google_Service_Exception

html - IE8 在标准模式下忽略斜杠前的零宽度空格

javascript - 当浏览器大小改变时改变背景视频的大小

javascript - jQuery 中 .parent() 的奇怪结果

javascript - 将 url anchor 从 javascript 变量传递到 php 变量

html - 鼠标悬停不能实时工作,在预览中工作

angularjs - angular js中图像的URL

css - 如何在不给它(或其父级)明确高度的情况下防止内联 SVG 以任意高度显示?