SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question prev and next navigation doesn't work ...

    Hi friends,
    Can anybody tell me why this simple script doesn't work? Present month and year is coming (fortunately!!!) but I can't navigate to previous and next months ... Thanks for any help if possible.
    Regards.

    Code:
    <html>
    	<head><title>Building Dynamic Site</title>
    	</head>
    
    	<body bgcolor="#FFF4CE">
    
    	<table align="center" cellpadding="3" cellspacing="1" border='0'>
    
    	<tr><td align="center">
    
    	<?php $month_now=date('n'); $year=date('Y');
    
    	if ($submit) {	
    	
    	if (isset($_GET['prevmonth'])) { $month_now--;} else {$month_now++;} }	
    
    	$month=date('M', mktime(0, 0, 0, $month_now, 1, date('Y') ));
    
    	 ?>
    
    	<form action="<?=$_SERVER['PHP_SELF']?>" method="get">
    
    	<input type="submit" name="prevmonth" value="<< Previous Month" /></td>
    
    	<td>
    
    	<input type="submit" name="nextmonth" value="Next Month >>"></td></tr>
    
    	<tr><td align="center" colspan="2">
    
    	<?php echo $month;?>&nbsp;<?php echo $year; ?>
    
    	</td></tr></table>
    
    	</body></html>

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    kigoobe,

    Yeah, your values are "Next Month >>" and "<< Previous Month" instead of <?= $month_now + 1 ?> and <?= $month_now - 1 ?>.

    Please note that you should do this remembering the New Year (Dec -> Jan and Jan <- Dec).

    edit: Also, type should be TEXT, NOT submit!

    Regards,

    DK
    Last edited by dklynn; May 29, 2004 at 03:29.
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn
    kigoobe,

    Yeah, your values are "Next Month >>" and "<< Previous Month" instead of <?= $month_now + 1 ?> and <?= $month_now - 1 ?>.

    Please note that you should do this remembering the New Year (Dec -> Jan and Jan <- Dec).

    edit: Also, type should be TEXT, NOT submit!

    Regards,

    DK
    Hi DK, Thanks for your help, but I am not getting what I am looking for basically. Changing the type to 'text' in place of 'submit', I loose the button which can be clicked to navigate back and forward. Also, changing the values could not help me as it seems 'value' has got only to do with the textual output of the 'submit' button.

    Let me know what u think if possible ...
    Thank u anyway for ur reply...

  4. #4
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I have done some more changes for the problem of January and December .. and the now the code goes in the following way ...
    What's surprising for me is that it is appearing everything is OK, but still the previous and next links are not working ... if anybody can figure out the problem, it will be helpfull. Thanks.


    Code:
    <html>
    	<head><title>Learning php</title>
    	
    	</head>
    
    	<body bgcolor="#FFF4CE">
    
    	<table align="center" cellpadding="3" cellspacing="1" border='0'>
    
    	<tr><td align="center">
    
    	<?php $month_now=date('n'); $year=date('Y');
    
    	if (isset($_GET['prevmonth'])) {
    
    	if($month_now == 1){ 
       	$month= date('M', mktime(0, 0, 0, 12, date('d'), date('Y')-1 )); 
    	} else { 
       	$month= date('M', mktime(0, 0, 0, date('n')-1, date('d'), date('Y') ));} }
    
    	if (isset($_GET['nextmonth'])) {
    
    	if($month_now == 12){ 
       	$month= date('M', mktime(0, 0, 0, 1, date('d'), date('Y')+1 )); 
    	} else { 
       	$month= date('M', mktime(0, 0, 0, date('n')+1, date('d'), date('Y') ));} } 	
    
    	
    	if (!$submit) {$month=date('M', mktime(0, 0, 0, date('n'), date('d'), date('Y') ));}	
    
    
    	 ?>
    
    	<form action="<?=$_SERVER['PHP_SELF']?>" method="get">
    
    	<input type="submit" name="prevmonth" value="<?=date('F', mktime(0, 0, 0, date('n')-1, date('d'), date('Y') ))?>" /></td>
    
    	<td>
    
    	<input type="submit" name="nextmonth" value="<?=date('F', mktime(0, 0, 0, date('n')+1, date('d'), date('Y') ))?>"></td></tr>
    
    	<tr><td align="center" colspan="2">
    
    	<?php echo $month;?>&nbsp;<?php echo $year; ?>
    	
    	</td></tr></table>
    
    	</body></html>

  5. #5
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to everybody who visited this question, with special thanks to DK, who tried to help me ... I have got the solution ... Wish u all nice time.

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    kigoobe,

    Quote Originally Posted by kigoobe
    Thanks to everybody who visited this question, with special thanks to DK, who tried to help me ... I have got the solution ... Wish u all nice time.
    You're very welcome! I'm constantly learning from this site and am trying to return the favor.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •