我有此代码分页和此代码用于测验后点击下一步将会话和标题(位置)保存到下一页进行测验。
现在我想在点击输入下一个加载下一页...
后加载没有刷新页面的下一页<?php
$cid = (int)$_GET['id'];
if(!isset($_GET['page'])){
$page = 1;
}else{
$page = (int)$_GET['page'];
}
$records_at_page = 1;
$q = $db->query("SELECT * FROM `questions` WHERE `cat`='".$cid."'");
$records_count = $q->num_rows;
$pages_count = (int)ceil($records_count / $records_at_page);
if(($page > $pages_count) or ($page <= 0)){
die('No More Pages');
}
$start = ($page - 1) * $records_at_page;
$end = $records_at_page;
$next = $page + 1;
$prev = $page - 1;
$qui = isset($_POST['val']);
if(isset($_POST['next'])){
$tst = $_SESSION['val'] = $qui;
$_SESSION['value'] = ($_SESSION['value'] + $tst);
if($next <= $pages_count){
header('Location: quiz.php?id='.$cid.'&page=' .$next. '');
}
if($next > $pages_count){
echo '<a href="result.php?id='.$cid.'">Result</a>';
exit;}
}
if($records_count != 0){
$ar = $db->query("SELECT * FROM `questions` WHERE `cat`='".$cid."' order by `id` desc LIMIT $start,$end");
while($rowar = $ar->fetch_object()){
echo"
<form ation='' method='POST'>
<div>".$rowar->question."</div>";
$ans = $db->query("select * from `answer` where `question_id`='".$rowar->id."' order by `id` desc");
$rowans = $ans->fetch_object();
echo"
<div ><input class='rgt' type='radio' name='val' value='".$rowans->val1."'/><p>".$rowans->answ1."</p></div>
<div><input type='submit' name='next'value='Next'/></div>
</form>
";
}
}
?>