Hi,
Some general PHP help please on how to use a foreach loop for me to get tide data in a spefic table format.
I already use foreach loops for my forceast data and can use a foreach loop to get data in a table for the tides but I can only work out how to get one set of data on a row ( 4 x columns), which means it a very long table. Like so:
Day Event Time Height
Monday High Tide 09:10 6.9m
Monday Low Tide 21:15 0.6m
Tuesday High Tide 09:30 6.7m
etc.etc, you get the idea
What I would like to have is 3 sets of data on each row like this
Day Event Time Height Day Event Time Height Day Event Time Height
Monday High Tide 09:10 6.9m Monday Low Tide 21:15 0.6m Monday Low Tide 21:15 0.6m
Tuesday High Tide
You can see what I mean here, http://midlifedad.me.uk/weather/eastbourne_tides.phpbut when I first put this together, I hadnt learnt about "foreach" so literally created a variable from the json file for each entry and ended up having around 250 variables, not very efficient.
Data is being pulled from the UK Admiralty and it also uses Mark's charts to display. I'm ok formatting the actual data into days, times etc. But I can only get it to read the first foreach for each row so the data for each set of 4 colums is always the same on that row. (Hope that makes sense). Ive trawled through StackOverflow and many pages of php examples but cant find what I need.
Sample of the data from the json file is below.
[
{
"EventType": "LowWater",
"DateTime": "2022-01-24T05:10:00",
"IsApproximateTime": false,
"Height": 0.9433952546253683,
"IsApproximateHeight": false,
"Filtered": false,
"Date": "2022-01-24T00:00:00"
},
{
"EventType": "HighWater",
"DateTime": "2022-01-24T10:17:00",
"IsApproximateTime": false,
"Height": 5.444324680328854,
"IsApproximateHeight": false,
"Filtered": false,
"Date": "2022-01-24T00:00:00"
},
{
"EventType": "LowWater",
"DateTime": "2022-01-24T17:35:00",
"IsApproximateTime": false,
"Height": 0.8888834979599549,
"IsApproximateHeight": false,
"Filtered": false,
"Date": "2022-01-24T00:00:00"
},
{
"EventType": "HighWater",
"DateTime": "2022-01-24T22:38:00",
"IsApproximateTime": false,
"Height": 6.008938731402115,
"IsApproximateHeight": false,
"Filtered": false,
"Date": "2022-01-24T00:00:00"
},
{
"EventType": "LowWater",
"DateTime": "2022-01-25T05:50:00",
"IsApproximateTime": false,
"Height": 0.8994946691625086,
"IsApproximateHeight": false,
"Filtered": false,
"Date": "2022-01-25T00:00:00"
},
Any pointers would be grately appreciated.
Andy
Welcome to the Cumulus Support forum.
Latest Cumulus MX release 3.16.1 (build 3183) - 06 May 2022
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
If you are interested in supporting Cumulus then maybe you would like to contribute to the maintenance of the Wiki? This need not take hours of your time - just a half hour here and there can make a big difference, particularly if many people are doing this. Any contributions are very welcome, whether they involve new content or editing of existing content. It will be very helpful to current and future users of Cumulus software if the Wiki is kept well-maintained and current. If you are interested then please contact forum user saratogaWX and ask for a Wiki account.
Latest Cumulus MX release 3.16.1 (build 3183) - 06 May 2022
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
If you are interested in supporting Cumulus then maybe you would like to contribute to the maintenance of the Wiki? This need not take hours of your time - just a half hour here and there can make a big difference, particularly if many people are doing this. Any contributions are very welcome, whether they involve new content or editing of existing content. It will be very helpful to current and future users of Cumulus software if the Wiki is kept well-maintained and current. If you are interested then please contact forum user saratogaWX and ask for a Wiki account.
Help with PHP tables for tide data
Moderator: daj