Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.5 (build 3282) - 23 February 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Top 10 Records Page

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Top 10 Records Page

Post by mcrossley »

To stop hi-jacking the other thread, I thought I 'd start a new one for the Top 10 page.

<edit 04/07/18>
Updated to version 2.1, the script can now be directly embedded in a content page, it no longer includes the page structure.

You can see my version here.

I have put together a generic page to demo the script here

The main content script source code is here.
And the source for the generic page content showing how to use the script is here.
</edit>

This was inspired by Dans (captzero - brisbaneliveweather) pioneering work, though I developed my code independently.

It is still a work in progress, take it and alter it to your wishes.

If you want to retain colour gradients but alter them, I used this site to generate the code.

It may be worth reading the 'other thread' for a bit of background.
Last edited by mcrossley on Wed 04 Jul 2018 8:08 pm, edited 3 times in total.
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

Hi Mark

what values do I put in db_ro_details.php ? localhost,database,password, etc ?
but I don't know the syntax.

Thanks
water01
Posts: 3201
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Top 10 Records Page

Post by water01 »

Whatever is required to access your MySQL database on your server.

In my case

Code: Select all

<?php

// The server host name or number running your MySQL database
// usually 127.0.0.1 or localhost will suffice
$dbhost    = "localhost";
//
// The username used to log-in to your database server
$dbuser    ="UserName";
//
// The password used to log-in to your database server
$dbpassword   ="Password";
//
// The name of the MySQL database we will store the tables in
$database   ="dmjsyste_cumulus";

?>
Good idea to make this file read/write by User only using CHMOD or Filezilla to change permissions.
David
Image
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

Thanks David
Graham64
Posts: 74
Joined: Mon 23 Aug 2010 5:04 pm
Weather Station: Davis Vantage Pro 2
Operating System: Windows XP
Location: Cornwall, England
Contact:

Re: Top 10 Records Page

Post by Graham64 »

Mark
Another excellent script - thanks.
Just one query, how come the Min Wind Chill value is identical to Min Temp?
A coincidence or have I missed something?
Thanks once again for your inspirational scripts - I am learning a lot.
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Post by mcrossley »

I don't know, I need to go and look at the data more closely. My "all time" records in Cumulus show the same thing, so I think the DB is right - as far as it goes.

Edit: I think those really low temps were overnight when the wind tends to drop to zero (or the anemometer is frozen up!)

I also need to look at why my lowest humidity is coming up as 100%!
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Post by mcrossley »

OK, the humidity problem is caused by the day file table having the high/low humidity fields defined as varchar(3) so SQL was performing a text based sort (100 < [anything above 19]). I have amended the ImportCumulusFile script to declare them as decimal(4,1) to fix this.

For my own table, as I have a Davis which only supplies integer humidity values I have changed my field definitions to int(3) and that has sorted the problem out. (That is a hint for those that do not know, you can change table field types on the fly so long as the data contained in them is compatible. You do not have to drop the whole table and recreate it)
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

Hmm confusing I get a ERROR - Bad Select Statement (1) error I use the old databse from David (the first one) http://apeldoorn.tk/weer/top10.php
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

I think the error is caused due I've no solardata in them :bash:
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Post by mcrossley »

The script is written for the DB schema as defined in ImportCumulusFile v2.0 or later. But any data you do not have, just delete or comment out those lines in the $dataArrays object - they will then not appear on the final web page either.
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

Thanks Mark I give it a try and will update de database later , will the new database not affect my older scripts ?
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Post by mcrossley »

It may do, I'd suggest doing a parallel install first with different table names. Then check your old scripts one at a time against the new tables. Once you are happy you can then either drop the old tables and carry on with the new, or if you want to retain the original names you can drop the old and rename the new tables to the old names. (don't forget to also change the ImportCumulusFiles script to reflect the old names again if you do this).

Edit: On reading back that explanation is as clear as mud!
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

Thanks for your advice , I saw the new database contains a lot more data so its time to step over
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Post by nitrx »

LOL I think I better setup an extra database I keep get errors

I also don't understand this

Code: Select all

$query = "SELECT LogDate, ROUND($fld, $dec) " .
             'FROM Dayfile'.
in the code above he table is selected but in the oter queries the is no table selected

Code: Select all

$query = 'SELECT MAX(LogDate) AS date_to, COUNT(*) cnt ' .
             'FROM (' .
Or is this usual :mrgreen:
User avatar
mcrossley
Posts: 12641
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Post by mcrossley »

Ron the second one is a compound query, you feed the results from one query into another, so the outer 'from' is referring to the results of the inner query rather than a table, it is sometimes the only way of getting the data aggregated how you want it.
Post Reply