Hi Marcel,
Whilst there isn't a webtag as such, I do a similar thing on my website , although in fact I ask the exact opposite, as in the UK it is nice to know how many days it didn't rain!
I use a MYSQL query to do this so you do need to be running this on your site, although there may be other ways to do it through Java scripts.
This is the query and code I use for the current year, which other members from the forum helped me create:
Code: Select all
$querytydnr='SELECT COUNT(TotRainFall) as daysnorain FROM Dayfile WHERE YEAR(LogDate)=YEAR(NOW()) AND TotRainFall=0';
$resulttydnr=mysql_query($querytydnr)or die('Error: '.mysql_error());
.
.
<?php while($row=mysql_fetch_object($resulttydnr)){?>
<td><?php echo $row->daysnorain;?></td>
<?php
}
?>
You would, I guess, change the "...AND TotRainFall=0" in the query to "...AND TotRainFall>0" to get the number of days it rained.
You can obviously change it to look at per month as well, but I found this to be more complicated for some reason (I am not a MYSQL expert, in fact I am a complete novice so my code is not what you would call "tight" and hence the reason why my month code is done in a different way to my year code), but through trial and error I got it to work:
Code: Select all
<?php $resulttysmdnr=mysql_query("SELECT COUNT(TotRainFall) as daysnorain FROM Dayfile WHERE YEAR(LogDate)=YEAR(NOW()) AND MONTH(LogDate)=$mo AND TotRainFall=0")or die('Error: '.mysql_error());?>
<?php while($row=mysql_fetch_object($resulttysmdnr)){?>
<td><?php echo $row->daysnorain;?></td>
<?php
}
?>
For the month query, I wanted it based on a user selected month hence the $mo variable which is passed through a "select" drop down box code option.
Hope that helps you in some small way, as many others have helped me on here
