level 2
无闻之风
楼主
我弄了个在线答题功能,根据回答过的问题的正确率调整下一题难度,但现在问题是会出现重复题目,用了这个结构还会有,不知道为什么,求大神解惑:
if($_SESSION['singlenum']>0){
$result[]=$_SESSION['result'];
do{$sql="select * from cpl_single where difficulty='".$condition_a."' and (chapterid<".$_SESSION['chapterid']." or chapterid=".$_SESSION['chapterid'].") order by rand() limit 1;";
$list=$model->query($sql);
$i=$list[0]['id'];
}while (in_array($i, $result)) ;
$result[]=$i;
$_SESSION['result']=$result;
$_SESSION['singlenum']=$_SESSION['singlenum']-1;
$tablename="Single";}
2016年06月04日 07点06分
1
if($_SESSION['singlenum']>0){
$result[]=$_SESSION['result'];
do{$sql="select * from cpl_single where difficulty='".$condition_a."' and (chapterid<".$_SESSION['chapterid']." or chapterid=".$_SESSION['chapterid'].") order by rand() limit 1;";
$list=$model->query($sql);
$i=$list[0]['id'];
}while (in_array($i, $result)) ;
$result[]=$i;
$_SESSION['result']=$result;
$_SESSION['singlenum']=$_SESSION['singlenum']-1;
$tablename="Single";}