Kindly let 开发者_运维技巧me know how can I put the limit on the record in the below function. I want to fetch all the record but one first page I want to show 5 only. Like pagination.
while (($row = mysqli_fetch_array($rd)) ){
}
$times = 5;
while (($row = mysqli_fetch_array($rd)) && $times-- > 0){
}
However, this is not recommended! Use a limit
clause in the SQL query instead, to avoid using a lot of CPU power for getting records you're not going to use anyway.
$limit = 0;
while (($row = mysqli_fetch_array($rd)) && $limit < 5){
$limit++;
}
精彩评论