PHP code to find how many pages an external link might have - php

I need to find a way to know how many pages an external link might have depending on the products i choose to see per page.
eg:
This link might have 36 products and I'm asking to see 5 products per page:
https://externalsite.com/cat/dvd-cat/sub-cat/?per_page=5
When I click on page two, I get the link this way:
https://externalsite.com/cat/dvd-cat/sub-cat/page/2/?per_page=5
What I need to find is how many pages the first URL will have in PHP

Related

Building webpages that are indexed for mutiple items and such

I'm moreless curious about webpages that are indexed. An example is gamestop. When you are looking through their product lists they have indexed for multiple tabs like 123456 on the near the bottom of the page. I also notice this with many search engines and pages selling products. I know it sounds dumb to ask a question like this, but I've always been curious how to code a mutiple indexed page like the example listed above. I hope you fellow coders out there could provide some sample code to demonstrate this idea would be perfect. Plus, it could help me in future to see just how it is done. Please provide any info you can. Thank you :)
Actually the INDEXING you are referring is called Pagination. Whenever you have multiple items/Records and you want to show only some of them in one page and rest on the other. e.g. you have 100 records in the database and you want to show all of them but loading all at once will slow down your page. So what programmers do is, they use pagination.
What they do is , They will show first 10 records on one page. if you have 100 records in database. Then first page will show records from 1 to 10, 2nd page will show 11 to 20 and so on till the end.
use reference
http://code.tutsplus.com/tutorials/how-to-paginate-data-with-php--net-2928
or
Simple PHP Pagination script

WordPress - Get all of current page's queries information

Okay... so here is what I'm trying to do. Basically all of the components that make up any particular page on a Wordpress site, I need to be able to grab the query that WP is running to grab the data for that particular area of the given page. So, if we have page A, let's say it has a top navigation, main content section, and footer. Each of these three areas have content that is pulled from the database. I need a generic way to say on page X I want to know what queries have been ran to generate all of the content pulled from the database and displayed on the page.
I feel like the key is to properly use https://codex.wordpress.org/Class_Reference/WP_Query to get the data I need.
Any thoughts on how I could go about this?

For Google crawling purposes: Single PHP pull-page, or individual pages for each different item?

I am creating a site and want to have individual pages for each row in a database table. The information on each page is fairly useful and comprehensive, and it would be really nice if Google could index them.
My initial thought was to just create a single PHP template page and pull the correct information for whatever the user is looking at, but my fear is that search engines won't be able to index all of the pages.
My second thought was to batch-create/automate the process of creating the individual pages as html files (for the 2000+ rows in the table), because then I would be guaranteed that they'd be crawled. However, if I ever needed to make a change to the design, I'd have to re-process them all. Kind of a pain...
My final consideration was to just pick a page in my site and list all of the possible php pages in a hidden div, but I wasn't sure if search engines can index from that. I assume they just pull from the HTML, so it'd be able to find it, right?
Any suggestions? I would love it if I can just create a single page that populates based on what they user clicks, but I want them to be indexed.
Search engines can index dynamic pages so using one PHP file to create thousands of unique product pages will be fine for SEO. After all, each page/product will have a unique URL and will be seen as a unique page as a result. All you need to do is link to your product pages within your website and/or submit an XML sitemap so you can be sure they are found and indexed.
By linking your pages, I literally mean link to your product pages. Search engines find new content primarily through following links. So if you want your product pages to be found you need to link to them. Using form based search is not a good way to do it as search engines generally don't play to well with forms. But there are lots of way to make links to your pages including HTML sitemaps and product category pages which then can link to products in that category. Really, any way yo u an get a link to your product pages is a good way to help ensure they are found by the search engines.
You don't have to post links on invisible DIV!
Just create the page and have parameterized content fetching.
You can include the pages in the XML sitemap and submit to Google or you can include your page urls in the HTML sitemap too.

Internal page - don't want it crawled

Please indulge my simplistic example:
Let's say I have 1 million pages on my site. Each page has an ID number (i.e. www.mysite.com/product.php?id=1 .... upto id=1,000,000
I want to make a page that allows users to email themselves the link to the page (or email a friend). This page is also dynamic and comes from the product.php, so like this:
www.mysite.com/email_a_friend.php?id=1 .... upto id=1,000,000
Imagine I do this and now google wants to crawl 2 million pages instead of 1 million. This seems pointless since the page doesn't have anything of any value on the email page. Also, consider that the email page would actually be a pop-up window on the product.php page.
What is the best way to handle this?
Should I block it (email_a_friend.php) through a robots.txt file?
Or should I perhaps used java or something else for the link that google would ignore anyway?
Thanks!!
If I'm understanding your question correctly, you have an e-commerce site and want to implement a share button for a particular product. What you don't want to happen is have google index the page that the share button goes to.
If that's the case, just add a rel="nofollow" to the link in your php that generates the link and you should have no problem.
Here is a google help article that explains how google does not follow links with the nofollow attribute: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=96569

How to query full page from a phpbb forum?

I want to write an app that parse particular threas on a phpbb forum. So if a thread has 200 pages with 10 posts (that doesn't give you the ability to adjust the post count per page), and has an address like this:
http://www.forum.com/viewtopic.php?t=10&postdays=0&postorder=asc&start=0
where start parameter changes when you navigate to the next pages of the same thread, how do you get the full thread in one go?
I tried:
http://www.forum.com/viewtopic.php?t=10&postdays=0&postorder=asc&start=0&end=2000
but didn't work.
Surely there must be a way to do this I imagine.
If you're parsing, just parse each page, then add up the results in the end. If the forum doesn't have an open API, or any way to display all of the posts on one page, this is what your are going to have to do. Perhaps you could write a recursive function that checks for a 'next page' link or something similar, follows it, then returns all of the data from the pages compiled.
EDIT: looking at example url you gave, have you tried changing the t variable? you said it was 10 posts per page, and that was set to 10, so maybe that's what controls posts per page.
http://www.forum.com/viewtopic.php?t=2000&postdays=0&postorder=asc&start=0
Some super handsome fellow wrote a MOD for this if it is your forum:
http://www.phpbb.com/community/viewtopic.php?f=69&t=1101295

Categories