GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech PHP Pagination Question(s). (https://gfy.com/showthread.php?t=1348630)

Publisher Bucks 09-26-2021 12:24 AM

PHP Pagination Question(s).
 
So this week my goal is to setup pagination on my recipe site but, before I dive in I was hoping to get some feedback.

I've been researching a few different options, mainly whether I should begin with recipes.php?page=0 or recipes.php?page=1 as the first page, does either option matter significantly?

I have read in a few places then when dealing with potentially hundreds of pages, using OFFSET can cause issue?

Secondly, I'm thinking of using this for the main code snippet:

Quote:

$page_number = mysqli_escape_string($con, $_GET['page']);
$count_per_page = 20;
$next_offset = $page_number * $count_per_page;
$cat =mysqli_query($con, "SELECT * FROM Recipes LIMIT $count_per_page OFFSET $next_offset");
while ($row = mysqli_fetch_array($cat))
$count = $row[0];
Is that the simplest way of achieving what I need to happen (main results page, with navigation to X amount of other pages) or will the OFFSET stuff cause issue because the items on the page is low thus generating hundreds of pages?

Also, is that TOO simple and restrictive as far as the functions go of generating the page navigation?

Finally, when it comes to the navigation itself, is it best (in your experience) to just have numerical pages listed or should I also include a 'PREVIOUS' and 'NEXT' link on the navigation structure?

Thanks in advance for any advice and feedback you can offer :thumbsup

ZTT 09-26-2021 05:59 AM

Unfortunately nobody can really answer your questions as well as you can yourself, because nobody but you knows what you want to achieve.

Personally I would never use pagination even if the fate of the world depended on it, but then I also wouldn't use a database or PHP when it can be avoided, and I have no idea why you're trying to code everything from the back end to the front end yourself when there are plenty of recipe templates and themes already out there.

I think it would actually be less of a chore, and would provide a far better, more interesting/personalized experience for visitors, to simply write a blog on Wordpress.com, adding 10 recipes per day, at least if there's some genuine enthusiasm and knowledge about the subject, than grinding away on what seems to be just another recipe dump like hundreds of others that already exist.

To specifically address your questions:

Quote:

"whether I should begin with recipes.php?page=0 or recipes.php?page=1 as the first page, does either option matter significantly?"
Machines typically count from 0; humans from 1. That's it. Just use whatever works in your code, because no internet user, including you, has ever cared whether a URL has a 0 or 1.

Quote:

"I have read in a few places then when dealing with potentially hundreds of pages, using OFFSET can cause issue?"
Why would you even have hundreds of pages? It's a scientific fact that no human in their right mind (who wasn't stealing/scraping content) has ever clicked further than page 5 of anything.

Quote:

"when it comes to the navigation itself, is it best (in your experience) to just have numerical pages listed or should I also include a 'PREVIOUS' and 'NEXT' link on the navigation structure?"
Pagination is always the worst solution - almost nobody reads past page one anyway, and nobody at all cares about more than 100 items of anything, so even if you don't want to lazy load, just put 100 results on one page and let people find other stuff in other ways, such as categories or 'related' suggestions.

If you absolutely must use the worst, most tedious navigation method ever, you can again answer your own question - is it nicer when there's a big PREVIOUS and NEXT button to click, or is it better when you have to exactly hit an 8x8 pixel arrow or number?

You're a user too; if you think something makes things easier, do it, and if you think it makes things harder, don't do it. Certainly never let 'style', which is subjective anyway, override user experience.

Publisher Bucks 09-26-2021 10:09 AM

Quote:

Unfortunately nobody can really answer your questions as well as you can yourself, because nobody but you knows what you want to achieve.
I'm sure that several people have advice on whether certain functions, features and methods can put a strain on a server based on their own experiences or what can or can't make a site load slower based on those same functions, features and methodologies.

Quote:

I have no idea why you're trying to code everything from the back end to the front end yourself when there are plenty of recipe templates and themes already out there.
Because I'm teaching myself to code using .php, sure there are thousands of Wordpress templates and themes out there but if I use one of those, I'll not learn anything about coding.

Quote:

Machines typically count from 0; humans from 1. That's it. Just use whatever works in your code, because no internet user, including you, has ever cared whether a URL has a 0 or 1.
Unless it comes to placing extra server strain/load resulting in negative load times due to having to recount pagination functions each and every time a web page loads.

Quote:

Why would you even have hundreds of pages? It's a scientific fact that no human in their right mind (who wasn't stealing/scraping content) has ever clicked further than page 5 of anything.
Because having hundreds of pages is a good way to get niche specific traffic to a recipe site directly from the search engines, being able to filter results based on ingredient, recipe type or cooking method is going to generate hundreds of pages and in theory will attract a larger source of organic traffic over time.

Based on your opinion, no website anywhere should ever have more than 5 pages. There go all the TGPs, Link Lists, Directories, Review Sites and Pay Site Tours with previews, even GFY has a lot more than 5 pages listed on their page navigation for the forum. :Oh crap

Quote:

Pagination is always the worst solution - almost nobody reads past page one anyway, and nobody at all cares about more than 100 items of anything, so even if you don't want to lazy load, just put 100 results on one page and let people find other stuff in other ways, such as categories or 'related' suggestions.
As mentioned, its not just about the end-user experience, but also for the search engines.

Quote:

You're a user too; if you think something makes things easier, do it, and if you think it makes things harder, don't do it. Certainly never let 'style', which is subjective anyway, override user experience.
I'm also a site owner and while user experience is a large part of owning a website, profitability, design, functionality and layout in addition to style are all important aspects of owning a website.

I appreciate your opinions though and will definitely take them into account, thank you :)

fuzebox 09-26-2021 01:00 PM

Jesus dude, take this to stackoverflow or something.

ZTT 09-26-2021 03:25 PM

Quote:

Originally Posted by Publisher Bucks (Post 22917678)
I'm sure that several people have advice on whether certain functions, features and methods can put a strain on a server based on their own experiences or what can or can't make a site load slower based on those same functions, features and methodologies.

Unless it comes to placing extra server strain/load resulting in negative load times due to having to recount pagination functions each and every time a web page loads.

This is the point: you're not asking about a problem you have, you're asking about a problem that doesn't exist, and may never exist. Pagination has been used for 20 years, on 20 year old hardware with 20 year old software and code, so why are you worrying so much that it will take down your 2021 server?

The best way to find out is to simply try it and see if there are issues or not. Worrying about it in advance is just a waste of time and energy.

BTW, your answer as to why you're coding it all is a good one. :thumbsup Good luck.

plsureking 09-26-2021 06:21 PM

with pagination, what i like to do is email the visitor the current page, then ask them to enter it on a special form at the bottom of the page. once submitted, i like to shoot a support request over to my ISP and ask them to turn the page.

:2 cents:

#

brassmonkey 09-27-2021 05:01 AM

is it wp pr a php script?

zijlstravideo 09-27-2021 05:19 AM

Quote:

Originally Posted by plsureking (Post 22917833)
with pagination, what i like to do is email the visitor the current page, then ask them to enter it on a special form at the bottom of the page. once submitted, i like to shoot a support request over to my ISP and ask them to turn the page.

:2 cents:

#

Don't forget the sms verification to verify the request first...:smokin


OP's website should have a "Proudly powered by GFY" statement in the footer by now.:winkwink:

Klen 09-27-2021 07:12 AM

Quote:

Originally Posted by fuzebox (Post 22917754)
Jesus dude, take this to stackoverflow or something.

Stackoverflow is evil :1orglaugh

plsureking 09-27-2021 08:18 AM

Quote:

Originally Posted by zijlstravideo (Post 22917956)
Don't forget the sms verification to verify the request first...:smokin


OP's website should have a "Proudly powered by GFY" statement in the footer by now.:winkwink:

:1orglaugh i gotta update my script

#

brassmonkey 09-27-2021 12:35 PM

Quote:

Originally Posted by Klen (Post 22917990)
Stackoverflow is evil :1orglaugh

a guy actually fixed a error in my script there :2 cents::2 cents:


All times are GMT -7. The time now is 02:05 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123