gpt4 book ai didi

php - 明智地获取和显示记录部分

转载 作者:行者123 更新时间:2023-11-29 12:07:18 25 4
gpt4 key购买 nike

3 个表quiz_sectionsquiz_attemptsquestion_attempts 表的列如下面所附的屏幕截图所示。

$USER->id 是当前登录的用户 ID 变量。

这是我的代码

<?php
echo "Current User ID : ".$USER->id."<br />";
$quizsections = mysql_query("SELECT * FROM quiz_sections");
while($quizsectionsrslt = mysql_fetch_array($quizsections)){
echo $quizsectionsheading = $quizsectionsrslt['heading']."<br />";
$quizsectionsquizid = $quizsectionsrslt['quizid'];
$quizsectionsfirstslot = $quizsectionsrslt['firstslot'];
$quizattempts = mysql_query("SELECT * FROM quiz_attempts WHERE `quiz`=$quizsectionsquizid AND `userid`=$USER->id");
while($quizattemptsrslt = mysql_fetch_array($quizattempts)){
$quizattemptsids = $quizattemptsrslt['id'];
$quizattemptsattempt = $quizattemptsrslt['attempt'];
$quizattemptsquiz = $quizattemptsrslt['quiz'];
$questionattempts = mysql_query("SELECT * FROM question_attempts WHERE `questionusageid`=$quizattemptsids");
while($questionattemptsrslt = mysql_fetch_array($questionattempts)){
echo $questionattemptsid = $questionattemptsrslt['id'];
}
}
}

我得到的输出

enter image description here

enter image description here

我想拆分userid=3的结果

资质

1 2 3 4...10

算术

11 12 13 ...20

推理

21 22 23 ...30

计算机

31 32 33 ...40

userid=4 的结果从 41 到 80。

这些是表结构。

enter image description here

enter image description here

enter image description here

最佳答案

您需要在问题尝试查询中使用$quizsectionsfirstslot:

$questionattempts = mysql_query("SELECT * FROM question_attempts 
WHERE `questionusageid`=$quizattemptsids
AND slot BETWEEN $quizsectionsfirstslot AND $quizsectionsfirstslot + 9");

关于php - 明智地获取和显示记录部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31261550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com