Home  >  Q&A  >  body text

Guys, what should we do?

<?php

session_start();

header("Content-type:text/html;charset=utf-8"); //Set encoding

$page=isset($_GET['page']) ?$_GET['page'] :1 ;//Receive page number

$page=!empty($page) ?$page :1 ;

$F=$_GET['F'];

// Create connection

$conn = mysqli_connect("localhost", "root", "", "mybbs");

mysqli_set_charset($conn,'utf8'); //Set the character set

$table_name="tiopic";//Get the table name setting

$perpage=5;//Number of data displayed on each page

//Maximum number of pages and total number of records

$total_sql="select count(*) from $table_name ";

$total_result =mysqli_query($conn,$total_sql);

$total_row=mysqli_fetch_row($total_result);

$total = $total_row[0]; //Get the maximum page number

$total_page = ceil($total/$perpage);//Upward integer

//Critical point

$page=$page> $total_page ? $total_page:$page;//What happens when the next page number is greater than the maximum number of pages

//Paging setting initialization

$start=($page-1)*$ perpage;

$sql="select * from tiopic order by id desc limit $start ,$perpage";

$query=mysqli_query($conn,$sql);

$sum=mysqli_num_rows($query);

?>

QQ图片20190220155224.pngQQ图片20190220155214.png

还好还好2042 days ago1090

reply all(5)I'll reply

  • TT

    TT2019-02-21 08:43:04

    It is estimated that either the function in line 24 is not supported, or there is a problem with the parameters passed in by 24.

    reply
    0
  • 马先生

    马先生2019-02-20 22:19:52

    First run your sql statement in the database to see if there is any result, and then dump the result of $query. This is a warning, not a fatal error. $sum should be the number of rows returned. You can output it to see look

    reply
    0
  • 学院里的小寂寞

    学院里的小寂寞2019-02-20 17:22:08

    You have to read this error message. This error message reminds you that the mysqli_num_rows() method expects the boolean value of mysqli_result to be 1, which is on line 24 of the D:\XXX path\forums.php file

    reply
    0
  • 还好

    How to operate it specifically? I’m a novice and don’t really understand this.

    还好 · 2019-02-20 17:24:52
  • Cancelreply