小编the*_*one的帖子

查询限制被忽略

我有这个代码,它计算列中的所有行correct并igonringLIMIT 5

被忽略的代码行


$last5rate = $db->prepare("select sum(correct) 
from exams where username = :username ORDER BY testID DESC LIMIT 5");
Run Code Online (Sandbox Code Playgroud)

这是整个代码


<?php

require('includes/config.php'); 

//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); } 
$username = $_SESSION['username'];
$last5rate = $db->prepare("select sum(correct) from exams where username = :username ORDER BY testID DESC LIMIT 5");
$last5rate->execute(array(':username' => $username));
for($i=0; $rows = $last5rate->fetch(); $i++){
    //Edit this row
$last5  = $rows['sum(correct)'];
$last5final = $last5 / 10;
 }
echo $last5final;

?>
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法 …

php pdo sql-limit

2
推荐指数
1
解决办法
50
查看次数

标签 统计

pdo ×1

php ×1

sql-limit ×1