Jump to content

[SOLVED] $_get


adam291086

Recommended Posts

Thanks, Works great.

 

The problem i am now facing is that when i set the url to what i want it returns an odd result.

 

<a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?php echo $nextmonth; ?>?y=<?php echo $thisyear; >">Adam</a></th>

 

Whats happening is

when i echo

$_GET['m']

i just get the result 1 which is correct. But when i echo

$_GET['y']

i get the result ?=2008. I dont want the ?= and just 2008.

 

 

Link to comment
Share on other sites

ok all is working well aprt from this. In my claedar i have a next button.

 

//next month
$nextmonth = $thismonth+1;
if($nextmonth >12)
{
$thisyear = date('Y')+1;
$nextmonth = "1";
}

 

problem being when i get to december 2008 and click next it says january 2008 again. This is due to %thisyear being taken from the current year. How do i get around this and make it say january 2009.

 

 

Link to comment
Share on other sites

ok now i have created a previuos button, problem is that. When i get to january 2009 and click previous i get dec 2008, which is correct. When i click previous again i get nov 2009. Can anyone see why.

 

<?php
//previous month
$premonth =$thismonth-1;
if($premonth <1)
{
$thisyear = $thisyear-1;
$premonth = '12';
}
?>
  <a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?php echo $premonth; ?>&&y=<?php echo $thisyear;?>">Previous Month</a>

 

just edit the english and the date part

Link to comment
Share on other sites

It's not working because you haven't fully grasped how to use date() and mktime() in combination to create a dynamic selector. You'll just need to keep playing with it. Go to php.net and look up the functions:

date

mktime

strtotime

strftime

 

The most important part here is, read through the User comments and pick up little bits of code advice through their examples. In many cases, through the user comments, you will see that particular function used just about every creative way possible. But keep trying... all of this learning to use time and date functions is extremely valuable, and many otherwise really good coders unfortunately never git 'r done.

 

PhREEEk

Link to comment
Share on other sites

Try this to get you started:

 

$month = $_GET['m'];

$year = $_GET['y'];

 

$next = mktime(0,0,0,$arr_month[$month]+1,1,$year);

$next = $_SERVER['PHP_SELF']."?m=".date("F", $next)."&y=".date("Y", $next);

 

$prev = mktime(0,0,0,$arr_month[$month]-1,1,$year);

$prev = $_SERVER['PHP_SELF']."?m=".date("F", $prev)."&y=".date("Y", $prev);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.