Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Bootstrap3表中显示这些php搜索结果_Php_Twitter Bootstrap - Fatal编程技术网

如何在Bootstrap3表中显示这些php搜索结果

如何在Bootstrap3表中显示这些php搜索结果,php,twitter-bootstrap,Php,Twitter Bootstrap,我想使用php显示数据库中的信息,但需要使用Bootstrap3而不是默认的html表标记来设置表的样式。我需要帮助来解决这个问题,以便更好地了解如何使用php显示搜索结果。谢谢 <?php $connect = mysqli_connect("localhost", "root", "", "oas"); if ($connect) { $search = ""; $query = "SELECT distinct(M.`s_id`) as `s_id`,

我想使用php显示数据库中的信息,但需要使用Bootstrap3而不是默认的html表标记来设置表的样式。我需要帮助来解决这个问题,以便更好地了解如何使用php显示搜索结果。谢谢

<?php
$connect = mysqli_connect("localhost", "root", "", "oas");
if ($connect) {

    $search = "";

    $query = "SELECT distinct(M.`s_id`) as `s_id`,
                     M.`s_mark`,
                     U.`s_name`
                     FROM `t_usermark` as M
                    JOIN `t_user_data` as U on M.s_id = U.s_id  WHERE `s_name` like '%$search%'";
    $result = mysqli_query($connect, $query);

    if ($result) {
        if (mysqli_num_rows($result) > 0) {
            echo "
                    <table>
                        <tr>
                            <th>ID</th>
                            <th>Name</th>
                            <th>Mark</th>
                        </tr>
                    ";
            while ($row = mysqli_fetch_array($result)) {
                $id = $row['s_id'];
                $mark = $row['s_mark'];
                $name = $row['s_name'];

                echo "
                            <tr>
                                <td>$id</td>
                                <td>$name</td>
                                <td>$mark</td>
                            </tr>
                        ";

                // echo "<p>$id</p><p>$mark</p><p>$name</p>";
            }

        } else {
            echo "No results";
        }

        echo "</table>";
    } else {
        echo mysqli_error($connect);
    }
} else {
    echo "Database connection failed";
}

?>

试试这个

    <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <title>Search result  </title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<?php
$connect = mysqli_connect("localhost", "root", "", "oas");
if ($connect) {

$search = "";

$query = "SELECT distinct(M.`s_id`) as `s_id`,
                     M.`s_mark`,
                     U.`s_name`
                     FROM `t_usermark` as M
                    JOIN `t_user_data` as U on M.s_id = U.s_id  WHERE `s_name` like '%$search%'";
$result = mysqli_query($connect, $query);

if ($result) {
    if (mysqli_num_rows($result) > 0) {
        echo "<table>
                        <tr>
                            <th>ID</th>
                            <th>Name</th>
                            <th>Mark</th>
                        </tr>
                    ";
        while ($row = mysqli_fetch_array($result)) {
            $id = $row['s_id'];
            $mark = $row['s_mark'];
            $name = $row['s_name'];
                echo '<tr>
      <th scope="row">'.$id.'</th>
      <td>'.$name.'</td>
      <td>'.$mark.'</td>
    </tr>';
            }

            echo '
</tbody>
</table>';
        } else {
            echo "No results";
        }

        echo "</table>";
    } else {
        echo mysqli_error($connect);
    }
} else {
    echo "Database connection failed";
}

?>

搜索结果

不会为您这样做,但是,将类表添加到表标记中,然后将使用引导样式设置它的样式。

1)仅将引导CSS文件添加到页面本身并不会使表以引导样式设置格式。2) OP特别询问了bootstrap 3,而不是4。