Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Month events

  1. #1
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Month events

    I have registers in a mysql DB and I want to show them for months. I think I have a var like this:



    PHP Code:
    $id "month(now())"
                    
    $sql "select * from agenda_geral where agenda='desporto' and month = ".$id." and area_ID = 1 order by day" 
    But what I have to do for show the next or the previous month events in the same page without create a new??

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Tried:
    Code:
    $sql = "select * from agenda_geral where agenda='desporto' and month = ".$id+1." and area_ID = 1 order by day" ;
    ?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    But how can I change the month with links?

    Example:

    Code:
    <p><a href="agend_desporto.php??????"> Previous </a> | <a href="agend_desporto.php??????"> Next </a></p>

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, I see.
    Code:
    $modifier = isset($_GET['modifier']) ? mysql_real_escape_string($_GET['modifier'], $conn) : 0;
    $sql = "select * from agenda_geral where agenda='desporto' and month = ".$id+$modifier." and area_ID = 1 order by day";
    ... where $conn is the resource handler for the connection to the database (the return value of mysql_connect or _pconnect).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry!! I don't understand!!!

    What about the links?? What should I put for pass for the previous or for the next month like a calendar??

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    For a previous month:
    Code:
    agend_desporto.php?modifier=-1
    For the next month:
    Code:
    agend_desporto.php?modifier=1
    For a year ago:
    Code:
    agend_desporto.php?modifier=-12
    For seven months from now:
    Code:
    agend_desporto.php?modifier=7
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    PHP Code:
    $conn mysql_connect(SERVER,DBUSER,DBPWD) or die ("Problemas na ligação MySQL");
                      
    $id "month(now())";
                    
    $modifier = isset($_GET['modifier']) ? mysql_real_escape_string($_GET['modifier'], $conn) : 0;
                    
    $sql "select * from agenda_geral where agenda='desporto' and month = ".($id+$modifier)." and area_ID = 1 order by day" ;
                        
    $queryl query($sql) or die ("Query failed: " mysql_error() . " Actual query: " $sql);
                    echo (
    $id $modifier); 
    The test echo below gives 1 when I click <a href="agend_desporto.php?modifier=1"> Previous </a> and -1 when I click <a href="agend_desporto.php?modifier=-1"> Previous </a>

    Why doesn't gives the actual month minus or plus the modifier??

  8. #8
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It&#180;s fix.

    But I have another question...how can I increment or decrement the var modifier for pass to others months like a calendar, when I click several times on a link?

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's impossible (or very difficult, at least). You'd have to modify the link.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    At this moment I have:

    Code:
    <p>
    			  <a href="agend_desporto.php?modifier=-1"> Anterior </a> | 
    			  <a href="agend_desporto.php?modifier=0"> Actual </a> | 
    			  <a href="agend_desporto.php?modifier=1"> Seguinte </a>
    		  </p>
    And I tried to do with months:

    Code:
    <p>
    			  <a href="agend_desporto.php?modifier=-3"> <? //echo trata_month($arrl["month"]-3) ?> </a><br />
    			  <a href="agend_desporto.php?modifier=-2"> <? //echo trata_month($arrl["month"]-2) ?> </a><br />
    			  <a href="agend_desporto.php?modifier=-1"> <? //echo trata_month($arrl["month"]-1) ?> </a><br /> 
    			  <a href="agend_desporto.php?modifier=0"> <? //echo trata_month($arrl["month"]) ?> </a><br /> 
    			  <a href="agend_desporto.php?modifier=1"> <? //echo trata_month($arrl["month"]+1) ?> </a>
    		  </p>
    Code:
    function trata_month($data)
    {
    				 switch ($data){
    							case 1:
    								$data = "Janeiro"; 
    							break;
    							
    							case 2:
    								$data= "Fevereiro"; 
    							break;
    							
    							case 3:
    								$data = "Mar&#231;o"; 
    							break;
    							
    							case 4:
    								$data = "Abril"; 
    							break;
    							
    							case 5:
    								$data = "Maio"; 
    							break;
    							
    							case 6:
    								$data = "Junho"; 
    							break;
    							
    							case 7:
    								$data = "Julho"; 
    							break;
    							
    							case 8:
    								$data = "Agosto"; 
    							break;
    							
    							case 9:
    								$data = "Setembro"; 
    							break;
    							
    							case 10:
    								$data = "Outubro"; 
    							break;
    							
    							case 11:
    								$data = "Novembro"; 
    							break;
    							
    							case 12:
    								$data = "Dezembro"; 
    							break;
    						}
    				 
    				return $data;
    }
    When I do that some months modify or doesn't appear. Why?? What can I do correct this code?

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
  •