Forum Moderators: coopster
this is what currently exists:
max # of results per pages (10)
max # of pages (unlimited)
but let's say there's only 50 results. naturally, there shouldn't be anything showing past page 5.. so if someone tries to enter /myscript.php?page=6 they would get a 404 response/error
i have tried searching php.net extensively, but i cannot put it into few words what i need to do, therefore i'm not finding the correct tutorials or examples.
can anyone help me out?
I think it would be very unwise to generate a 404 header.
a) It's confusing for visitors
b) you might find your page removed from search engines.
c) See above: it's simply not true
look at it in this scenario:
- 50 products in database that show on this file
- i sell 10, which means i lost a page.
- search bots are still hitting that last page, and getting a 200/ok response.. note that this is replicating the last REAL page (page 4)
- i get slapped with a duplicate content penalty; and users will be confused when they hit page 5, then click to page 4.. they're getting the same content on two different pages
i don't want to 404 pages 1-4, any page after that needs to be 404'd to prevent this duplicate content penalty and confusing visitors
$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, p. manufacturers_id, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW); MAX_DISPLAY_PRODUCTS_NEW is defined in the database as configuration.
so you don't do any limiting, you just grab the whole thing every time
you should be able to do a mysql_num_rows and figure out if that page is within range and return a 404 if not
MAX_DISPLAY_PRODUCTS_NEW is basically the cutoff point for which i want to be displaying the records, because they become obsolete after that point
$num = mysql_num_rows($result);
if($_GET['page']>($num/10)){
//code to do on error
}