-1

I want to echo some text based on the page id in the url, for example if the page is 72 i want to output "mens"

products_new.php?categories_id=72

i dont know where to start but im guessing im looking to write some php that says something like: if : products_new.php?categories_id=72 then echo 'Mens'

any ideas, im using oscommerce?

Brad
  • 1
  • 1
    The best strategy would be to fetch the category from the database based on the parameter being passed on the url. You want the name of category that has the id 72. – Jorge Guberte Aug 20 '11 at 20:58

4 Answers4

2

That's part of the querystring, you can just check $_GET['categories_id'], not the whole path.

Cyclone
  • 17,939
  • 45
  • 124
  • 193
1

Values sent through the url are available in the $_GET superglobal array:

$id = $_GET['categories_id'];

if ($id == 72)
{
    echo "Mens";
}
Major Productions
  • 5,914
  • 13
  • 70
  • 149
1

You can use $_GET['categories_id'] to get that page id, which can then be displayed.

Joey
  • 344,408
  • 85
  • 689
  • 683
vicky
  • 11
  • 1
0

Once you get the category id from the query string (as in Cyclone's answer) you will probably pick up the value "Mens" not from a conditional statement but from a database table or a PHP array in memory that maps the category ids to their descriptions.

Don't use an if statement for this, especially if you have a lot of categories!

Ray Toal
  • 86,166
  • 18
  • 182
  • 232
  • there are only 5 main ones i need to pull in, i get what you mean though, would be unmanageable! the above solution works for now – Brad Aug 20 '11 at 21:09