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

Database v text files

From build 3044 the development baton passed to Mark Crossley. Mark has been responsible for all the Builds since. He has made the code available on GitHub. It is Mark's hope that others will join in this development, but at the very least he welcomes your ideas for future developments (see Cumulus MX Development suggestions).

Moderator: mcrossley

Sadgit
Posts: 192
Joined: Sun 04 Jan 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: Database v text files

Post by Sadgit »

well not that easy.. I went purely for php so my code has every line with

Code: Select all

echo "  </tr>\n";
echo "  <tr class=\"td_temperature_data\">\n";
echo "    <td>Temperature</td>\n";
echo "    <td>$temp $tempunit></td>\n";
echo "    <td>Dew Point </td>\n";
echo "    <td>$dew $tempunit></td>\n";
echo "  </tr>\n";
not the most efficient I suspect. I take it the best way is to ensure I just use php language wehn actually needed and stick to html where possible?
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Database v text files

Post by sfws »

Sadgit wrote: Thu 23 Apr 2020 6:20 am not the most efficient I suspect. I take it the best way is to ensure I just use php language wehn actually needed and stick to html where possible?
It is not as simple as that. Yes there are 2 approaches (all php or stick to HTML to extent possible). But which is better depends on what your aim is:

Writing in HTML as much as you can and only within each table cell using a piece of PHP just to output the value is simplest because you get a web page that is easy to read (just do view source in your browser and you see the whole structure).
sfws wrote: Sun 19 Apr 2020 8:25 am<tr>
<th class="label">Total Rainfall</th>
<td class='site_data'><?php echo "$rfall $rainunit"; ?></td>
<td></td>
<td class='site_data_RH'><?=$rfallY . ' ' . $rainunit;?></td>
<td></td>
</tr>
Writing mostly in php, getting PHP to write out all the structure has the disadvantage that you can't see that if you use "view source" in your browser.
Sadgit wrote: Thu 23 Apr 2020 6:20 am]echo " <tr class=\"td_temperature_data\">\n";
echo " <td>Temperature</td>\n";
echo " <td>$temp $tempunit></td>\n";
echo " <td>Dew Point </td>\n";
echo " <td>$dew $tempunit></td>\n";
echo " </tr>\n";
It is not for me to say which is best for you. Yes, it is marginally more inefficient to enclose in double quotes content that is not variables, so the PHP manual will say your third line above should read to give maximum efficiency for the PHP parser:

Code: Select all

echo "\t" . '<td>' . $temp . ' ' . $tempunit . '</td>' . "\n";
My own opinion (your choice) is that my approach is best for a beginner writing a simple web page, but if you want to vary your web page according to content (i.e. use "If ... else .." conditions or other ways of changing content) then it is simpler to do more in PHP rather than continually swap between PHP and pure HTML. In particular you don't actually need to write separate rows, but can loop through repeating on structure that can be labelled temperature one time and rainfall another. Plus it is easier to do multiple web pages in one skeleton.

I started using PHP years and years ago and I experimented with all the possibilities because I like to feel I have tried everything. My more recent coding has gone back to mostly HTML because it looks so much better, you can see the source easily in your browser, and layout is not a question of adding the right number of "\t" and "\n"! Ok I now do each page separately with less shared, but in some ways that gives me more flexibility.
Sadgit
Posts: 192
Joined: Sun 04 Jan 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: Database v text files

Post by Sadgit »

Thanks for the detailed replies. I'm trying to stick mainly to html as you say it is easier to read and I did get sick of putting a / instead of a \

I'm trying to keep it simple so far (too much sun to spend it inside on a laptop :) ) but with the help help here and some search engine fun, I'm getting the hand of it. I won't have anything fancy, but I will be able to display the basics for now... Cheers
Sadgit
Posts: 192
Joined: Sun 04 Jan 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: Database v text files

Post by Sadgit »

Hi Mapantz, you say your records script is a sql version, I found he tops 10s, I've searched all over the forum but cannot find one. Any pointers please? I know lots of questions from me lately, but enjoying getting data imported in my DB and setting up my new site. Finally moving away from my sluggish old site, setup and host!

Cheers
Mark
water01
Posts: 3670
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10/11 64bit Synology NAS
Location: Burnham-on-Sea
Contact:

Re: Database v text files

Post by water01 »

Well done. But that is the hard part and sorting out the errors.

Code: Select all

Warning: Invalid argument supplied for foreach() in /home4/markrennie71/public_html/get-USNO-sunmoon.php on line 361

Warning: Invalid argument supplied for foreach() in /home4/markrennie71/public_html/get-USNO-sunmoon.php on line 372
:D :D :D :D

Also your site initially builds the header and the sidebar with the menu and then takes quite a long time to load the rest of the Home page.
David
Image
Sadgit
Posts: 192
Joined: Sun 04 Jan 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: Database v text files

Post by Sadgit »

Ahhh that is the old site on the new host.. Not even looking at that one :D

Takes years to load hence making my own and starting from scratch.
water01
Posts: 3670
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10/11 64bit Synology NAS
Location: Burnham-on-Sea
Contact:

Re: Database v text files

Post by water01 »

So where is the new one so we can all take a look. :D :D
David
Image
Post Reply