我想通过分页显示每页一条记录,直到显示所有记录为止,页面导航必须类似于“下一个上一个完成”。 这是我的代码,用于查看问题表中的记录。
<form class="form-horizontal" role="form" id='login' method="post" action="result.php">
<?php
$number_question = 1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from questions where category_id=$category and level_id=$level ORDER BY RAND() LIMIT $limit");
$total = mysqli_num_rows( $row );
$page = $total/$number_question;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?></p>
</br>
<?php echo '<img src="data:image/png;base64,'.base64_encode($result['image']).'" />'; ?></br><br/>
<input type="text" name="answer" placeholder="Enter your answer" required />
<br/>
<br/>
</div>
<?php
if ( $total > $number_question ) {
if ( $j == 1 ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$j++;
} elseif ( $j > 1 ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$j++;
}
}
$k++;
} ?>
</form>
有人可以帮我使用分页吗? 谢谢