I have a paginator that shows the following for page 1
records 1 through 10
10 being the number of records per page. Thing is for new users they might have under 10 records so showing 10 as the # per page doesn't work
How can I do something like this
if total_record_count is < 10, show total_record_count ELSE show 10 (records per page)
Thanks
Well there's always Enumerable#min:
<%= [posts.count, 10].min %>
Related
I have some problem to count total record using WHERE clause condition with pagination in Laravel.
Ex: I have total 100 records (female students = 40 and male student = 60) and display 10 records per page.
So I want to count total records of female student when display in homepage.
I have tried like this {{$StudentInfo->where("sex",1)->count()}} but it count record only in current page not all record and when I used total() it does not work {{$StudentInfo->where("sex",1)->total()}}.
Note: sex = 1 (female), sex = 0 (male).
Thanks.
{{$StudentInfo->where("sex",1)->get()->count()}}
Hope this works..
Do $StudentInfo->total();
Check the docs: https://laravel.com/docs/7.x/pagination
Hello Everyone can you please help me to resolve this
I want to get the user count day-wise, for example, I want to know how many users registers in last week
like date of
22-07-19
user count 20
23-07-19
user count 30
24-07-19
user count 10
25-07-19
user count 15
I want this result for last 7 day from today
basically, I want to show this in my chart please check the image here
By selecting DATE(created_at) and grouping by that, we can get the count of users that have registered each day. We can then add a simple where clause, using Carbon to help us get the lower bounds.
Example (where x = date and y = count):
User::selectRaw('DATE(created_at) as x, COUNT(*) as y')
->groupBy('x')
->where('created_at', '>', Carbon::now()->subWeek())
->get();
I am trying the following
https://data.gov.in/api/datastore/resource.json/?resource_id=e16c75b6-7ee6-4ade-8e1f-2cd3043ff4c9&api-key=APIKEY&limit=200
I still get only 100 records. If I change the limit to 50 it gives me 50 records. How do I get the records from 101 - 200 and beyond?
I also tried using the offset parameter like so :
&offset=50
expecting it to give me record number 50-150, but it doesn't.
Does anyone have an Idea?
Try this query from OGD Platform.
you will find total_records = 2947 and count=100.
Here, you have total of 2947 records and maximum of 100 records can be fetched in one query. If you want next 200 result, set offset=2 which will give results from 201 to 300 and so on. You need to increase your offset by 1 in each query till 2947/100 = 29 (29th query will give 47 records) to get all data.
Parameter limit is used to fetch total number of records in each query and that will be between 0 to 100 (max). That's why when you set limit=50, you got 50 records but if you set limit=110, still you will get 100 records only.
Hope I my answer is clear enough. Good luck.
I'm showing 50 records per page. If 30 records have been deleted (or will not show for any other reasons) 1st page end index will 80 right? But second page index will be created 50 from pagination. So records between 50-80 indexes are shown both 1st and 2nd page.
How can I achieve this problem? Any ideas?
Feed the $config['total_rows'] variable in your pagination config the actual rows you want to show in view and it will calculate automatically, In other words count the total rows what you want to show, change the function of counting.
You must to recalculate current page based on max pages allowed after deletes:
Example, if your current page is $page, starting in 1:
$rowsByPage = 20;
$nrRows = ...count()...;
$maxPage = intval($nrRows / $rowsByPage) + 1;
then, adjust your page:
if($page > $maxPage) {
$page = $maxPage;
}
I am developing one custom search module in joomla. so I am using joomla's in-built database connection and function.
Problem is that I want to use pagination class in this module but don't know any hint.
Please help me on this.
Thanks.
Step 1: Get the total number of items in your database
ex: select count(*) from #__some_table where ....
Step 2: Import joomla pagination and create pagination object
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
where
$total = total number of items that you count in step 1
$limit = total number of items you want to display on a page
$limitstart = index of the first item in the page. For example if you have 20 items per page, 0 is start index for 1 page, 20 is start index for second and so on.
Step 3: Show pagination on your page
echo $pagination->getPagesLinks();
echo $pagination->getPagesCounter();