Agenda-script vraagje

Gestart doorKjeld11 reacties46 weergaven

12 berichten · pagina 1 van 1

Kjeld

Lid · Topicstarter

Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo biggrin
Ik ben nu weer bezig aan mijn agenda-script, wat ook in mijn carnavalsvereniging-site komt.
Nu is mijn tabel zo opgebouwd, en ik wil alle activiteiten van de maand laten zien waar op geselecteerd wordt.

+--------------------------------------------------------------------+
|     id     |     datum             |    activiteit        |
+-------+----------------------------------+------------------------+
|    1    |    2009-05-21 00:00:00    | Testactiviteit             |
|    2    |    2009-05-14 00:00:00    | Testactiviteit1             |
|    3    |    2009-04-21 00:00:00    | Testactiviteit2             |
+---------------------------------------------------------------------+


Met de volgende code krijg ik hetvolgende te zien:
Ik moet selecteren op 2009-5.
Er zijn deze maand geen activiteiten!

[COLOR= #0000BB]<?[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Ik moet selecteren op "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$getjaar[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"-"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$getmaand[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"."[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$vandaag[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y-m-d[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT *, UNIX_TIMESTAMP(datum) AS t_datum FROM agenda WHERE datum = NOW()"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br /><div class=melding>Er zijn deze maand geen activiteiten!</div>"[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]

    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]))
    {[/COLOR]
    
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] | [/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]activiteit[/COLOR][COLOR= #007700]];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];
    
    }
}[/COLOR]
?>


Hoe kan ik dit zo maken dat ik wel alle activiteiten van die maand te zien krijg?
Ik hoop dat iemand me hiermee kan helpen hypocrite.

Kjeld
0
Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik twijfel aan lijn 3 ;
".$getjaar."-".$getmaand.".";
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
De kolom datum is een timestamp denk ik zo, NOW() is echt NU, dus op de seconde nauwkeurig.
Hij zoekt dus alleen op de kolommen waarbij datum precies nu is, dus niet ergens in de maand mei van het jaar 2009.

Als je zoiets doet moet het wel werken:

$result = mysql_query("SELECT *, UNIX_TIMESTAMP(datum) AS t_datum FROM agenda WHERE datum = ".$vandaag);

Of helemaal in SQL:
$result = mysql_query("SELECT *, UNIX_TIMESTAMP(datum) AS t_datum FROM agenda WHERE MONTH(NOW()) = MONTH(datum) AND YEAR(NOW()) = YEAR(datum)");
0
Kjeld

Lid · Topicstarter

Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thnx, die 2e werkt biggrinDie eerste niet?
Maar dat maakt niet uit wink
//edit:

Kom er net achter dat er nog een vage bug zit in mn script emo
op http://www.derampestampers.nl/index.php?x=agenda laat hij wel de juiste datums zien, maar de link voor de admin die daar achter zit bevat de verkeerde datum..

Hoe kan ik dit aanpassen?
Betreffende code:

[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dagen[/COLOR] [COLOR= #007700]==[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]j[/COLOR][COLOR= #007700])[/COLOR] AND [COLOR= #0000BB]$getmaand[/COLOR] [COLOR= #007700]==[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]m[/COLOR][COLOR= #007700])[/COLOR] AND [COLOR= #0000BB]$getjaar[/COLOR] [COLOR= #007700]==[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y[/COLOR][COLOR= #007700]))
                {[/COLOR]
            
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td class="dagen"><b><a href="index.php?x=instellingen&pagina=agenda&actie=toevoegen&datum=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$huidigedatum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$getjaar[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$getmaand[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">
[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$dagen[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</a></b></td>[/COLOR][COLOR= #007700];
                
                }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
                
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td class="dagen"><a href="index.php?x=instellingen&pagina=agenda&actie=toevoegen&datum=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$huidigedatum[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$getjaar[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$getmaand[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]-[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">
[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$dagen[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</a></td>[/COLOR][COLOR= #007700];
            
                }[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Wat doet die $huidigedatum = $getjaar daarzo? emo
0
Kjeld

Lid · Topicstarter

Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen idee, foutje denk ik yummieMaar is iig gefixed nu wink
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Nice. emo
0
Kjeld

Lid · Topicstarter

Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hmmz.. het werkt nog niet yummie
Ofja, hij vraagt wel van de huidige maand op nu, maar ik kan bladeren tussen de maanden, en dan wil ik dat hij van die maand opvraagt..

$res = mysql_query("SELECT *, UNIX_TIMESTAMP(geb_datum) AS t_datum FROM leden WHERE MONTH(geb_datum) = MONTH(NOW())");

Wat moet ik dan veranderen?

de maand tijdens het bladeren is steeds $getmaand (1 = januari, 2 = feb, etc)
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$res = mysql_query("SELECT *, UNIX_TIMESTAMP(geb_datum) AS t_datum FROM leden WHERE MONTH(geb_datum) = ".$getmaand);

zo?
0
Kjeld

Lid · Topicstarter

Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ty emo
Wist niet dat het zo simpel was yummie
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Oh, t leven is zo vreselijk simpel.
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard is gewoon simpel
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren