If you use Cumulus, please donate Image

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Top 10 Records Page

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

Moderators: daj, TNETWeather

User avatar
mcrossley
Posts: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 8:35 am

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

You can see my version here.

The source code is here.

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 Sat Oct 04, 2014 9:30 am, edited 1 time in total.

User avatar
nitrx
Posts: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 8:47 am

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: 1399
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Top 10 Records Page

Postby water01 » Wed Oct 23, 2013 8:51 am

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.

User avatar
nitrx
Posts: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 9:00 am

Thanks David

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

Re: Top 10 Records Page

Postby Graham64 » Wed Oct 23, 2013 9:02 am

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: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 9:39 am

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: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 10:19 am

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: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 10:52 am

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: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 11:02 am

I think the error is caused due I've no solardata in them :bash:

User avatar
mcrossley
Posts: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 11:07 am

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: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 11:10 am

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: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 11:16 am

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: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 11:18 am

Thanks for your advice , I saw the new database contains a lot more data so its time to step over

User avatar
nitrx
Posts: 1300
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Top 10 Records Page

Postby nitrx » Wed Oct 23, 2013 11:38 am

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: 4967
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Wed Oct 23, 2013 11:59 am

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.


Return to “Web site - General”

Who is online

Users browsing this forum: Bing [Bot], caribike and 3 guests