Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-26-2021, 12:24 AM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
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
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2021, 05:59 AM   #2
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
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.
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2021, 10:09 AM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,111
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.

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
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2021, 01:00 PM   #4
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,004
Jesus dude, take this to stackoverflow or something.
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2021, 03:25 PM   #5
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Quote:
Originally Posted by Publisher Bucks View Post
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. Good luck.
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2021, 06:21 PM   #6
plsureking
bored
 
plsureking's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Metaverse
Posts: 4,675
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.



#
__________________
#

Last edited by plsureking; 09-26-2021 at 06:22 PM.. Reason: typo
plsureking is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-27-2021, 05:01 AM   #7
brassmonkey
Pay It Forward
 
brassmonkey's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Yo Mama House
Posts: 76,894
is it wp pr a php script?
__________________
TRUMP 2025 KEKAW!!! - Support The Laken Riley Act!!!
END DACA - SUPPORT AZ HCR 2060 52R - email: brassballz-at-techie.com
brassmonkey is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-27-2021, 05:19 AM   #8
zijlstravideo
Confirmed User
 
zijlstravideo's Avatar
 
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
Quote:
Originally Posted by plsureking View Post
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.



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


OP's website should have a "Proudly powered by GFY" statement in the footer by now.
__________________
Contact: email
zijlstravideo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-27-2021, 07:12 AM   #9
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Quote:
Originally Posted by fuzebox View Post
Jesus dude, take this to stackoverflow or something.
Stackoverflow is evil
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-27-2021, 08:18 AM   #10
plsureking
bored
 
plsureking's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Metaverse
Posts: 4,675
Quote:
Originally Posted by zijlstravideo View Post
Don't forget the sms verification to verify the request first...


OP's website should have a "Proudly powered by GFY" statement in the footer by now.
i gotta update my script

#
__________________
#
plsureking is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-27-2021, 12:35 PM   #11
brassmonkey
Pay It Forward
 
brassmonkey's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Yo Mama House
Posts: 76,894
Quote:
Originally Posted by Klen View Post
Stackoverflow is evil
a guy actually fixed a error in my script there
__________________
TRUMP 2025 KEKAW!!! - Support The Laken Riley Act!!!
END DACA - SUPPORT AZ HCR 2060 52R - email: brassballz-at-techie.com
brassmonkey is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
pages, offset, page, navigation, hundreds, $count_per_page, $page_number, main, issue, pagination, feedback, results, happen, amount, items, stuff, $next_offset;, simplest, $row[0];, $count, $row, achieving, low, mysqli_fetch_array$cat, finally



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.