Hello to all, welcome to therichpost.com. In this post, i will tell you, Laravel pagination using mysql limit offset.
Laravel is the top mvc framework in php.
Here is working and tested code for Laravel pagination using mysql limit offset:
// Paginate $limit = 2; //$_GET['page'] - get page number form url like - www.therichpost.com?page=1 $offset = (null !== $_GET['page']) ? ($_GET['page'] == 1) ? 0 : ($_GET['page']-1) * $limit : 0; $raw_sql = 'SELECT * FROM user'; //get total number of pages divided by limit $total_pages = sizeof(DB::select(DB::raw($raw_sql))) / $limit; $query = 'SELECT * FROM user LIMIT '.$limit.' OFFSET '.$offset; $user = DB::select(DB::raw($query));
If you have any query related to this post, then feel free to ask. the rich post
Recent Comments