Thank you to both of you for trying my script and giving feedback.
The schema I use for my database has worked well for me for many years, and made life simple for me. I guess David A Jamieson when he selected column names in creating ImportCumulusFile (the earliest I saw was version 1.3 when it had been revised by Mark Crossley) did not anticipate the sort of queries that might be used in the future. David, on his original website, simply had a historic graph using his database, his other scripts read the Cumulus log file directly. Mark Crossley's top ten script was something new to use the daily table, but it did not output any time-stamps and so did not consider the column names for those. My own version of Mark's top ten, did add time-stamps to the output and that was just one of several scripts by me that benefited from my choice of column names. Mark has changed David's schema in terms of the number of decimal places in some columns, but never (as far as I know) changed the original column names. Steve Loft when he added SQL generation to MX made provision for people to use their own schema, but used the Mark schema as his default. That is a long paragraph to set the context, but what it boils down to is that scripts that simply work well for me on my set-up (including handling time-stamps), need a lot of difficult tweaking to work with the set ups that others use.
PaulMy, you are using a database table that is set up using Mark's schema (ImportCumulusFile), but the HTML <option> tags in the HTML form are being populated with column names from my (SPAWS) schema. So it works if you happen to select a name in my schema that also appears in Mark's schema, but gives an error like
Unknown column 'TLastRainTip' in 'field list' query failure
if you pick a column in my schema that is not in Mark's schema. Well done for getting there otherwise, but you need to change the code around line 250 to read
Code: Select all
for($i = 0; $i < count($dayfileColumnsAndCaptions); $i++)
{
if(substr($dayfileColumnsAndCaptions[$i][1], 0, 10) != 'Time-stamp')
{
echo "<option title='". $i . '=' . $dayfileColumnsAndCaptions[$i][0]
. "' value='" . $dayfileColumnsAndCaptions[$i][0] . "'>" . $dayfileColumnsAndCaptions[$i][1] . '</option>';
}
}
PaulMy wrote:and improve the presentation...
Have fun! I have changed the looks on my own website on average probably about twice a year since I started, it is part of how I have learnt CSS. The pictures I posted in the other topic show the current look although the background picture is old it does give a good impression of how my latest arrangement of sensors looks.
======================
Mapantz wrote:PHP Notice: Undefined offset: 2 in /home/warehamw/public_html/cumulus/daily_pick.php on line 206
Line 206: echo "<option title='". $dayTableColumnsAndCaptions[$i][2]
Mapantz, you are using Cumulux MX, that generates a database table using by default what I call Mark's schema. You are correctly using the array that I generated for that schema "$dayfileColumnsAndCaptions" in the HTML form, but it does not include a "$dayTableColumnsAndCaptions[$i][2]" and that is still mentioned in your implementation, hence your error. The 'better' solution I give below will remove this error.
Mapantz wrote:Line 364: $tot[$rowArray['y1']] += $rowArray[$columnNameValue];
Actually, Mapantz, I realised after my post (but before your post) that this error could occur if, when selecting the column to display, you select a time-stamp. The above PHP instruction cannot add for example "06:20" and "09:01"!
There are two ways round this, either amend that line into
Code: Select all
if(is_numeric($rowArray[$columnNameValue])) $tot[$rowArray['y1']] += $rowArray[$columnNameValue];
or
and
this is
a much better solution amend the instructions around line 240
Code: Select all
<li>Select either a time-stamp, or an observation without an associated time-stamp, to display corresponding column</li>
<li>Select any field containing an observation that is associated with a time-stamp, to display both that column and the associated time-stamp</li>
</ol>
</aside>
<label for="field">Select <em>One</em> Daily Summary Column:</label>
<div class="enlarged"> <!-- the quoted class name should be associated with a larger font size -->
<select name="field" size="15">
<?php
for($i = 0; $i < count($dayTableColumnsAndCaptions); $i++)
{
// If you are using Mark's schema, use "$dayfileColumnsAndCaptions" version here, and delete other version:
# echo "<option title='". $i . '=' . $dayfileColumnsAndCaptions[$i][0]
# . "' value='" . $dayfileColumnsAndCaptions[$i][0] . "'>" . $dayfileColumnsAndCaptions[$i][1] . '</option>';
// The following "$dayTableColumnsAndCaptions" version is for SPAWS schema, if using it delete above version:
echo "<option title='". $dayTableColumnsAndCaptions[$i][2] . '; ' . $i . '=' . $dayTableColumnsAndCaptions[$i][0]
. "' value='" . $dayTableColumnsAndCaptions[$i][0] . "'>" . $dayTableColumnsAndCaptions[$i][1] . '</option>';
}
?>
</select>
to
Code: Select all
<li>Select an observation without an associated time-stamp, to display corresponding column</li>
<li>Select any field containing an observation that is associated with a time-stamp, to display both that column and the associated time-stamp</li>
</ol>
</aside>
<label for="field">Select <em>One</em> Daily Summary Column:</label>
<div class="enlarged"> <!-- the quoted class name should be associated with a larger font size -->
<select name="field" size="15">
<?php
for($i = 0; $i < count($dayfileColumnsAndCaptions); $i++)
{
if(substr($dayfileColumnsAndCaptions[$i][1], 0, 10) != 'Time-stamp')
{
echo "<option title='". $i . '=' . $dayfileColumnsAndCaptions[$i][0]
. "' value='" . $dayfileColumnsAndCaptions[$i][0] . "'>" . $dayfileColumnsAndCaptions[$i][1] . '</option>';
}
}
?>
</select>
In case it is not clear, the changes are to remove mention of selecting a time-stamp, to change which array is counted in the for loop, and to place an 'if' instruction round the echo within the 'for' loop to exclude any '<option>' line that displays a caption starting with 'Time-stamp'. Apologies, that I did not make it possible for you to get this right with the code in my zip.
Mapantz wrote: I got it working quite easily
I presume this layout is correct?
Glad you got it working easily. Yes, that is the layout I saw when I was testing the script I was going to put in this topic.
Mapantz wrote:If I have some time later in the week, I'll have a go at tarting it up with some CSS.
The previous "MySQL code help" topic initiated by Paul includes some screen shots of how my own CSS makes it look with the HTML <summary> tags formatted as buttons (I don't actually like those button colours, but they were selected for a different script) and various colours for backgrounds and borders of different parts of the page. My website can only be seen on my two PCs, but I am always saying when I have time I will work out a better look. But I like to be outdoors, and I tend to use my computer either when I can't sleep or when I am tired and I retreat back indoors, not the best times to create masterpieces of design!
Given that I have needed to give some replacement code above, I will try to find time to update my zip making it a little clearer in that particular area, and if I remember I will include some CSS as an example starting point to help you (and anyone else) develop CSS to tart it up!