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?
4
Answers
That’s part of the querystring, you can just check
$_GET['categories_id']
, not the whole path.Values sent through the url are available in the $_GET superglobal array:
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!You can use
$_GET['categories_id']
to get that page id, which can then be displayed.