how to get the total row count with mysqli

前端 未结 3 715
轮回少年
轮回少年 2020-12-10 17:14

i am trying to understand mysqli extension and did google but got very few info on this except php.net which was helpful.

now after all this i am trying to achieve

3条回答
  •  死守一世寂寞
    2020-12-10 17:40

    using mysqli you do it the following way (assuming the mysqli object is already created -- you can also use the procedure methods, just slightly different):

    $sql = "SELECT SQL_CALC_FOUND_ROWS *, post.id as pid, bla bla 
            FROM account ORDER BY pid ASC". $eb["array"]['querylimit'];
    $result = $mysqli->query($sql);
    $TotalRcount = $result->num_rows;
    while($row=$result->fetch_assoc()){
        $col1 = $row['col1'];  // col1 is a placeholder for whatever column you are reading
        //read columns
    }
    

提交回复
热议问题