Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.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
Php 设计a";“柜台订购”;查询表_Php_Css_Sql - Fatal编程技术网

Php 设计a";“柜台订购”;查询表

Php 设计a";“柜台订购”;查询表,php,css,sql,Php,Css,Sql,我已经制作了一个脚本,通过desc0,5sql查询,根据大多数信用度,它为我提供了前5名玩家 这是在一个表中,但它并没有真正像我所说的那样去做,它所做的是它给出表头的每一行,而不是使它成为一个表() 这是我的php和css: <?php include('connect.php'); $result = $db->prepare("SELECT * FROM `tbl_users` WHERE `credits` >'0' ORDER BY `credits`

我已经制作了一个脚本,通过desc0,5sql查询,根据大多数信用度,它为我提供了前5名玩家 这是在一个表中,但它并没有真正像我所说的那样去做,它所做的是它给出表头的每一行,而不是使它成为一个表()

这是我的php和css:

<?php
    include('connect.php');
    $result = $db->prepare("SELECT * FROM `tbl_users` WHERE `credits` >'0' ORDER BY `credits` DESC LIMIT 0,5");
    $result->execute();
    for($i=0; $row = $result->fetch(); $i++){
?>

<!DOCTYPE html>
<html>

    <head>
        <link rel="stylesheet" href="style2.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <link href='https://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'>
    </head>

    <body>

    <div class="floated_elements">

    <table>

    <thead>
    <tr>
    <th> ID </th>
    <th> Wie </th>
    <th> Hoeveel </th>
    <th> email </th>
    </tr>
    </thead>

    <tbody>

    <tr>
    <td><?php echo $row['userID']; ?></td>
    <td><?php echo $row['userName']; ?></td>
    <td><?php echo $row['credits']; ?></td>
    <td><?php echo $row['userEmail']; ?></td>
    </tr>

    </tbody>

    </table>


    <?php
    }
    ?>

    </div> <!-- Closing floated elements -->

    <script>
    $('table tr').each(function(){
    $(this).find('th').first().addClass('first');
    $(this).find('th').last().addClass('last');
    $(this).find('td').first().addClass('first');
    $(this).find('td').last().addClass('last');
    });

    $('table tr').first().addClass('row-first');
    $('table tr').last().addClass('row-last');
    </script>

    </body>
</html>

您已经开始了
for
循环,并将所有内容都放入其中。这不是一个正确的方法。请尝试以下操作:

<?php
include('connect.php');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style2.css">
<script
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Great+Vibes'
    rel='stylesheet' type='text/css'>
</head>
<body>
    <div class="floated_elements">
        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Wie</th>
                    <th>Hoeveel</th>
                    <th>email</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $result = $db->prepare("SELECT * FROM `tbl_users` WHERE `credits` >'0' ORDER BY `credits` DESC LIMIT 0,5");
                $result->execute();
                for($i=0; $row = $result->fetch(); $i++){ ?>
                <tr>
                    <td><?php echo $row['userID']; ?></td>
                    <td><?php echo $row['userName']; ?></td>
                    <td><?php echo $row['credits']; ?></td>
                    <td><?php echo $row['userEmail']; ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <script>
    $('table tr').each(function(){
        $(this).find('th').first().addClass('first');
        $(this).find('th').last().addClass('last');
        $(this).find('td').first().addClass('first');
        $(this).find('td').last().addClass('last');
    });
    $('table tr').first().addClass('row-first');
    $('table tr').last().addClass('row-last');
    </script>
</body>
</html>

身份证件
Wie
霍维尔
电子邮件

哪里是
for
循环?for循环。。对我来说,新的东西,伊玛谷歌:)你会发布完整的代码吗?太多了!现在FOR规则是什么导致表知道如何显示?它确实是:)但是为了让我了解它,FOR规则将告诉表它应该如何表现?