【发布时间】:2016-01-08 20:18:05
【问题描述】:
我制作了一个脚本,通过 desc 0,5 sql 查询,根据大多数学分,我为我提供了前 5 名玩家 这是在一个表格中,但它并没有真正按照我的方式去做,它所做的是它提供表格标题的每一行,而不是将其作为 1 个表格 (see this screenshot)
这是我的 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 规则并尝试应用它,但并没有真正给出正确的结果
已编辑以提供要求的其他代码原因
【问题讨论】:
-
for循环在哪里? -
for loop.. 对我来说有些新东西,我在谷歌上搜索 :)
-
你会发布完整的代码吗?