garyw74 Posted December 16, 2008 Share Posted December 16, 2008 Hi Can some help me with this bit of code please. I am trying to reduce duplicate content on a shopping cart. If a product is in more than one category in the shop then this is indexed as two pages and in turn is classed as duplicate content The urls would be /catalog/product_info.php?cPath=45&products_id=5651 /catalog/product_info.php?products_id=5651 I have reduced the duplicate content by blocking the page with a cpath number by doing this <?php if ($_GET["cPath"] != '' ") { echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW">' ; } ?> The trouble is some URLs dont display a number so this doesnt work. /catalog/product_info.php?cPath=&products_id=5651 /catalog/product_info.php?products_id=5651 Is it possible to say - if cPath doesnt equal a number then display the NoINDEX Or any other suggestion would be appreciated Thanks Gary Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/ Share on other sites More sharing options...
Maq Posted December 16, 2008 Share Posted December 16, 2008 Looks like you're using osCommerce. A way to check would be to go to the products_to_categories table for the products that don't have a cPath in the URL and see if they have a category. You could do this manually and check a couple or just write a SQL query to check. Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/#findComment-717000 Share on other sites More sharing options...
garyw74 Posted December 16, 2008 Author Share Posted December 16, 2008 Thanks for the reply. Yes I am. I have checked this table and they all have a cpath listed. I think the software cant print out the cpath if its in more than two places. Presumably it has two cpaths because its in two places so the code doesnt display one or the other, just nothing. This is why the cpath is empty in the URL Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/#findComment-717010 Share on other sites More sharing options...
Maq Posted December 16, 2008 Share Posted December 16, 2008 Then why not grab the product_id and check it against the products_to_categories table. Here's how you would check if the product were in 0, 1, or more than 1 categories: if(isset($_GET['products_id'])) { $prod_id = $_GET['products_id']; $sql = "SELECT * FROM products_to_categories WHERE products_id = $prod_id"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($result); if($num > 1) { echo "This product is in MORE than 1 category!"; } elseif ($num == 1) { echo "This product is in ONLY 1 category!"; } else { else "This product ISN'T in any categories!"; } } Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/#findComment-717033 Share on other sites More sharing options...
garyw74 Posted December 16, 2008 Author Share Posted December 16, 2008 thanks very much, i will give that a go Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/#findComment-717048 Share on other sites More sharing options...
Maq Posted December 16, 2008 Share Posted December 16, 2008 It would be a lot easier to figure out a solution if you post code to a specific problem/example. Quote Link to comment https://forums.phpfreaks.com/topic/137249-check-for-a-number/#findComment-717055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.