使用"下一页"浏览答案和"前一页"

时间:2017-05-06 11:57:37

标签: php next

这是下面的代码!它在我的论坛中回答了特定问题的所有答案。我希望每页显示6个答案。因此,如果在一个特定问题上有12个答案,那么它应该从头开始显示前六个,然后用户点击"下一页"它应该向用户显示接下来的6个答案。我不知道如何在我的进步中解决这一步骤。任何帮助都非常感谢!感谢。

    <?php

    $tbl_name2="forum_answers"; // Switch to table "forum_answer"
    $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
    $result2=mysqli_query($con, $sql2)or die(mysqli_error($con));
   while($rows=mysqli_fetch_array($result2)){

?>


<!DOCTYPE HTML SYSTEM>

<table id="answers" width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td id="answerid">#<?php echo $rows['a_id']; ?></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" >
<tr>


<?php

INCLUDE 'dbh.php';
        $query = mysqli_query($conn,"SELECT * FROM forum_answers LEFT JOIN users ON forum_answers.a_name = users.username WHERE forum_answers.a_id=".$rows['a_id']." AND forum_answers.question_id=".$rows['question_id']);
        while ($row = mysqli_fetch_assoc($query)) {
            if ($row ['image'] == "") {

                echo "<img src='bilder/default.jpg'";
                ?><td width="77%" bgcolor="#F8F7F1"><a href="viewanswerprofiles.php"> <?php echo $rows['a_name']; ?></a></td><?php
            } 
            else { 
                echo "<img src='bilder/".$row ['image']."'";
                ?> <td width="77%" bgcolor="#F8F7F1"><a href="viewanswerprofiles.php"> <?php echo $rows['a_name']; ?></a></td><?php

            }
            echo "<br>";
        }
        ?>
<td id="datetimeanswer" bgcolor="#F8F7F1"><?php echo $rows['a_datetime']; ?></td>
</tr>
<tr>
    <td id="answertext" bgcolor="#F8F7F1"><strong>Answer:</strong></td>
    <td bgcolor="#F8F7F1"><?php echo $rows['a_answer']; ?>
        <button id="removeanswer" name="remove">Remove</button>
        <button id="removeanswer">Edit</button>
    </td>
</tr>
</table></td>

</tr>

</table>

0 个答案:

没有答案