I want to display one record per page through pagination untill all the records are displayed, navigation to pages must be like, Next Previous Finish. Here is my code to view the records from questions table.
<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>
Can Someone help me please to use pagination? Thanks