分页脚本添加了php页面,不会加载或显示任何错误

时间:2017-09-18 09:51:14

标签: php mysqli pagination

我尝试在我现有的sql查询的php页面中添加一个分页脚本。

但是在添加脚本后,页面将继续加载而不显示任何内容或错误。

我的代码如下:

<?php include('db.php'); ?>

<?php // define how many results you want per page
$results_per_page = 10;

// find out the number of results stored in database
$sql10='SELECT * FROM smf_messages';
$result10 = mysqli_query($conn, $sql10);
$number_of_results = mysqli_num_rows($result10);

// determine number of total pages available
$number_of_pages = ceil($number_of_results/$results_per_page);

// determine which page number visitor is currently on
if (!isset($_GET['page'])) {
  $page = 1;
} else {
  $page = $_GET['page'];
}

// determine the sql LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page-1)*$results_per_page;
?>

现在sql查询代码从各个表中获取数据......

<?php 
    $sql2 = "SELECT * FROM smf_log_digest WHERE note_type = 'topic' ORDER BY id_msg DESC LIMIT 420";
    $result2 = $conn->query($sql2);
    if ($result2->num_rows > 0) { 
    while($row2 = $result2->fetch_assoc()) { 
    $number = $row2["id_msg"];
?>

此查询涉及要检索的表的内容。

<?php                                               
    // retrieve selected results from database and display them on page
    $sql20='SELECT * FROM smf_messages WHERE id_msg = $number AND id_board = 4 LIMIT ' . $this_page_first_result . ',' .  $results_per_page;
    $result20 = mysqli_query($conn, $sql20);
    while($row20 = mysqli_fetch_array($result20)) {
    $member = $row20["id_member"];
    $replies = $row20["id_topic"];
?>
<?php
    $sqlstep1 = "SELECT COUNT(*) AS total FROM smf_log_digest WHERE note_type = 'reply' AND id_topic = $replies";
    $rowNumstep1 = mysqli_query($conn, $sqlstep1);
    $countstep1 = mysqli_fetch_assoc($rowNumstep1);                             
?>

// Body
<article class="well btn-group-sm clearfix">
       <div class="topic-desc row-fluid clearfix">
            <div class="col-sm-2 text-center publisher-wrap">
        <img src="assets/images/profile.png" alt="" class="avatar img-circle img-responsive">
        <h5><?php echo $row3["poster_name"]; ?></h5>
        <small class="online">Member</small>
       </div>
       <div class="col-sm-10">
          <header class="topic-footer clearfix">
       <!-- end tags -->
          </header>
       <!-- end topic -->
          <h4> <a href="post.php?id=<?php echo $row20['id_msg'];?>" style="font-weight: normal;"><?php echo $row20["body"]; ?></a></h4>
           <div class="blog-meta clearfix">
            <small><a href="post.php?id=<?php echo $row20['id_msg'];?>"><?php echo  $countstep1["total"]; ?> Replies</a></small>
             <small><?php echo date('m/d/Y', $row20["poster_time"]); ?></small>
           </div>
           <a href="post.php?id=<?php echo $row20['id_msg'];?>" class="readmore" title="">View the topic →</a>
        </div>
     </div>
</article>

//end of body

<?php 
    }
// display the links to the pages
for ($page=1;$page<=$number_of_pages;$page++) {
  echo '<a href="step1.php?page=' . $page . '">' . $page . '</a> ';
}

?>

<?php     }
    } else {
    echo "";
    }
?>

请注意,数据库连接都已经过检查,并且正确..

感谢任何帮助..

1 个答案:

答案 0 :(得分:-1)

将其添加到顶部然后检查错误。

error_reporting(E_ALL);
ini_set('desplay_errors','1');