If no variable is present in the URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wreed
Forum Newbie
Posts: 12
Joined: Wed Dec 18, 2002 12:12 pm
Location: Butler, NJ
Contact:

If no variable is present in the URL

Post by wreed »

I have a page, and if you just call the rankings.php page nothing shows, but if you call the variable in the url like so rankings.php?week=1 it shows the information I want. Now I just want to know if someone types in rankings.php I would like it to just print the latest week anyway, how do I look to the URL and see if there is a variable there?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

e.g.

Code: Select all

<?php
if (!isset($_GET['week']) || (int)$_GET['week'] < 1)
   $_GET['week'] = 1;
?>
Post Reply