How to count all records but only retrieve (LIMIT) a specific number for display?

后端 未结 4 1024
我在风中等你
我在风中等你 2021-01-13 12:29

I want to echo only the first 10 rows, but I need to count the total number of rows affected by the query.

I was doing a LIMIT 10 and then counting with

4条回答
  •  再見小時候
    2021-01-13 13:08

    count all records

    $data = mysql_query("SELECT * FROM Badges WHERE UID = '$user' ORDER by Date DESC");
    $count = mysql_num_rows($data);
    echo "No of Records is :" . $count;
    

    print 10 records...

     $data = mysql_query("SELECT * FROM Badges WHERE UID = '$user' ORDER by Date DESC LIMIT 0, 10");
        while($row = mysql_fetch_array( $data )) 
            { 
            echo $row['Site'];
            }
    

提交回复
热议问题