Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Display data from SQL in a table on your website

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Display data from SQL in a table on your website

Post by daj »

A number of people have asked how I do this on my site...

http://www.grantownweather.co.uk/historic/historic.php

Basically I am reading my dayfile.txt which I have stored in an SQL database on my webserver (see my other post on this). I then extract this data from SQL using PHP and show it in a table on my web pages.

There is a lot involved in doing this and many files (several javascript, styles sheets, images, PHP) It's a complicated process so is not for a beginner.

You need to edit dbconfig.php and look (and edit) historic.php, which calls read_dayfile.php (nothing needs editing in there as I have done all the work)

You can download all the files needed here.....http://www.grantownweather.co.uk/historic/DataTable.zip I think I have included everything!

Good luck
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
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: Display data from SQL in a table on your website

Post by nitrx »

Great I just posted mine :D , but I think yours is more sophisticated something to play this weekend
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: Display data from SQL in a table on your website

Post by nitrx »

In the dbconfig.php a wrong table is requested
the name of the SQL table holding the dayfile
$table_name="dayfile";

?>
I've changed the dayfile to Dayfile because thats the table where de data are stored (I got empty fields with the lowercase)
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: Display data from SQL in a table on your website

Post by daj »

The name of the table is whatever you called it when you imported it, so if yours is "Dayfile" then that is what this setting must be, whereas mine is actually called something complete different ;)
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
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: Display data from SQL in a table on your website

Post by nitrx »

Yep thats no surprise for me :) Well I need coffee right now
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: Display data from SQL in a table on your website

Post by daj »

It's not the weekend yet, so why are you playing with this? LOL

You said you would play with it at the weekend :lol:
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
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: Display data from SQL in a table on your website

Post by nitrx »

I planned a trip to Australia it's weekend over there ;)
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Display data from SQL in a table on your website

Post by n9mfk »

Hi All,
were do i change from c deg to f deg

http://www.n9mfk.com/historic/
Thanks Beau
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: Display data from SQL in a table on your website

Post by nitrx »

You already diid it I suppose ?
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Display data from SQL in a table on your website

Post by n9mfk »

Hi Ron,
I found an had delete to post but it did not delete
Beau
User avatar
GraemeT
Posts: 312
Joined: Wed 21 Oct 2009 11:19 am
Weather Station: La Crosse WS-2355 & WS-2306
Operating System: Windoze 7, 10, 11
Location: Bayswater, Australia
Contact:

Re: Display data from SQL in a table on your website

Post by GraemeT »

Hi David.

I've implemented your excellent MySQL history table with a fair degree of success.

Two points are worth a mention.

The first, regarding the 'colnames' definition. Is there any alternative to using <br/> to insert a line-feed in those headings which require two lines?
The xhtml spec says that <br/> isn't allowed. Not that it matters much to most browsers, though.

My second comment relates to dayfile.txt.
Lines in dayfile.txt since the Cumulus release which added 'Highest Average Wind Speed' and 'Time of Highest Average Wind Speed' are longer by 2 values.
This caused MySQL v5.1.43 to only use the most recent (longer) lines and then report errors for all the rest, having been told to expect 18 values, but only getting 16).
I added 2 dummy values (, 0.0, 00:00) to the end of all the short lines in my dayfile.txt (fortunately my history only goes back to late October).
It works ok, but I don't know if it's good for the longer term.

Cheers
Cheers,
Graeme.
TNETWeather

Re: Display data from SQL in a table on your website

Post by TNETWeather »

If you remove the <br/>'s what do you get. I suspect you will see what you want. Unless you use a &nbsp; with no spaces, the col headers are going to break due to the width of the columns anyway.
User avatar
GraemeT
Posts: 312
Joined: Wed 21 Oct 2009 11:19 am
Weather Station: La Crosse WS-2355 & WS-2306
Operating System: Windoze 7, 10, 11
Location: Bayswater, Australia
Contact:

Re: Display data from SQL in a table on your website

Post by GraemeT »

Hi Kevin,

First up, this is daj's code, not mine, I'm just making use of it.

Removing the <br/>'s stops the text wrapping around to the next line within the cell.
Using &nbsp; or a space doesn't cause a break, the text just disappears from view off to the right.
<br /> seems to be the only way to break the lines, but w3c validation fails at each occurrence in this case.
I suspect it's something in the way jquery operates, but I'll be the first to admit I have a LOT to learn
about php, javascript and mysql, (until 3 days ago I'd never used MySQL)
so if I've missed something here, let me know....

The pages below show what I mean.
The first page is the original history.php using <br/> and the second has spaces.
As you'll see, the second page doesn't have quite the same appearance.

http://weather.gktnet.com/history/historic.php

http://weather.gktnet.com/history/historic_.php
Cheers,
Graeme.
TNETWeather

Re: Display data from SQL in a table on your website

Post by TNETWeather »

Was just a thought. With normal cols in a table it would work, but I just tried doing it with your page and got the results you mentioned.

He is using JavaScript in the header section to deal with sorting etc... I suspect that it could be adjusted via CSS, but not really sure. He would be better and knowing what is going on.
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: Display data from SQL in a table on your website

Post by daj »

Hi Graeme
GraemeT wrote: The first, regarding the 'colnames' definition. Is there any alternative to using <br/> to insert a line-feed in those headings which require two lines?
The xhtml spec says that <br/> isn't allowed. Not that it matters much to most browsers, though.
There are a number of possible solutions -- I have had limited success with CSS. A quick 'cheat' to pass the XHTML spec is to move the Javascript to it's own file. So copy all the text between the last <script> and </script> but not the two tags, save it, then call it from within the document...<script src="build-table.js" type="text/javascript"></script>

To fully comply you need to 'fix' the blank table that is defined further down. I currently have a table with nothing in it and the Jquery fills it later. However XHML will not pass this so you would need to change it to include a row and a data cell...<table id="list"><tr><td></td> </tr></table>

It will now pass ;-) as mine does!


My second comment relates to dayfile.txt.
Lines in dayfile.txt since the Cumulus release which added 'Highest Average Wind Speed' and 'Time of Highest Average Wind Speed' are longer by 2 values.
This caused MySQL v5.1.43 to only use the most recent (longer) lines and then report errors for all the rest, having been told to expect 18 values, but only getting 16).
I added 2 dummy values (, 0.0, 00:00) to the end of all the short lines in my dayfile.txt (fortunately my history only goes back to late October).
It works ok, but I don't know if it's good for the longer term.
That is strange, as my dayfile.txt, like so many, will start off with the two fields missing at the end and then they appear after they were added to Cumulus. However they import no problem and are assigned no values. The script does not actually care how may fields it imports (I did that on purpose), but it then creates 18 and if there is no value in a field in the array it will be blank

Can you send me your dayfile just to try on my version (5.1.30)
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
Post Reply