[quote=“Multi”]hello there,
I’m going through ready examples and codes as part of my research in PHP, i’m still learning. I have this block of code, i kind of understand 70% of what it does. Would someone tell me what it does exactly i would be very greatful.
[php]
// Checks for a variable passed in the URL of month
// i.e. http://domain.com/index.php?month=13&year=2004
// This portion is if it’s at the end of a year
IF($_GET[‘month’] == 13){
// Presumably there is code that says CUR_MONT= 1
// Thus next month is CUR_MONTH +1 or 2
$next_month = 2;
// Just updating the year for NEXT year since we have moved
// to a new year (when getting to the end of the year)
$next_year = $_GET[‘year’] + 1;
} ELSE {
// So if the month is not 13 (i.e. LESS than 13)
// Next month is the current month PLUS 1
$next_month = $_GET[‘month’] + 1;
// I guess this is the next year being passed in the URL
$next_year = $_GET[‘year’];
}
// this portion is if it’s at the beginning of the year
// And is very similar to the portion above.
IF($_GET[‘month’] == 2){
$prev_month = 13;
$prev_year = $_GET[‘year’] - 1;
} ELSE {
$prev_month = $_GET[‘month’] - 1;
$prev_year = $_GET[‘year’];
}
[/php]
As I was looking through this I thought to myself that this was a horrible way to do this, but hind sight, It’s tough to say without seeing the entire code.
Any way… Hope this helps