Page 1 of 2

Re: Monthly records page with PHP tags.

Posted: Thu 19 Apr 2012 11:17 am
by beteljuice
Actually, that's just reminded me, it's one of the many things that I need to point to my new server host, everythings being 'double mapped' at the moment (but not all things work, because some of the server paths have changed :bash: )

Re: Monthly records page with PHP tags.

Posted: Thu 19 Apr 2012 3:16 pm
by duke
I agree too, I was just curious ;) .

Duke

Re: Monthly records page with PHP tags.

Posted: Thu 19 Apr 2012 6:25 pm
by duke
That's better. Image
... because I decided to give Lady beteljuice her garden back and removed my 30' anemometer mast !
May be she would consider letting you have a smaller one............

Duke

Re: Monthly records page with PHP tags.

Posted: Sun 29 Apr 2012 4:35 pm
by duke
So what's happening (or not) here :? ...........?

Finally got 10 mins to get back to this today, as I nearly had the page completed for Graemes webtags I've stayed with that for now but will implement Rays method when time allows.

Anyway, here is the page working, and here is the script and table cut n paste into one of my template pages with

Code: Select all

onload="changeData(<?php echo $month; ?>-1);"
added to the body tag but no data shows. I also notice that the js clock no longer appears on this page with the script added..... :?

Duke

Re: Monthly records page with PHP tags.

Posted: Sun 29 Apr 2012 11:11 pm
by beteljuice
You have changeData() in <body onload .........

Wonderfull CSS is one of the last things to be applied to a page, so the function can't "see" the ids it's trying to populate.

Put it as a seperate JS one-liner just before your closing </body> tag - should be OK ;)

Re: Monthly records page with PHP tags.

Posted: Mon 30 Apr 2012 8:24 am
by mcrossley
Your page does not display any data because there is none to display! All your array declarations in the javascript code are empty. So there is a problem in your PHP code somewhere which isn't adding the data to the page.

Re: Monthly records page with PHP tags.

Posted: Mon 30 Apr 2012 5:47 pm
by duke
Mark - I believe the PHP to be fine as I've just cut n paste from the working page into my template.

Beteljuice - at best my JS is extremely limited, what would be the one-liner I need to add?

Duke

Re: Monthly records page with PHP tags.

Posted: Mon 30 Apr 2012 11:01 pm
by beteljuice

Code: Select all

.....

<script type="text/javascript">
   changeData(<?php echo $month; ?>-1);
</script>

</body>


Re: Monthly records page with PHP tags.

Posted: Tue 01 May 2012 6:19 pm
by duke
beteljuice wrote:.....

Code: Select all

<script type="text/javascript">
   changeData(<?php echo $month; ?>-1);
</script>

</body>

Thanks beteljuice, that's actually what I had put in some where in the small hours of the morning but it still didn't work :bash: .

It is now how ever :shock: Turns out there were 2 issues, after I deleted everything not needed on the page and ran both through beyond compare.

1/ As beteljuice pointed out the code needed moving from the body tag to allow the script to run and to allow other scripts on the page to run. Having the code in the body tag stopped the clock scripts.

2/ @Mark, my apologies to you, you were also correct but I just could not see why. It was having the

Code: Select all

  <?php
  require_once("uploads/monthalltimewebtags.php");
  ?>
below the list of scripts. Moving this from below the list of js scripts on the page to above them allowed it to work. I assume the script was being run before the tags were processed and therefore no data to post.

Am I correct in my thinking???

My thanks to you both.

Duke

Re: Monthly records page with PHP tags.

Posted: Tue 01 May 2012 10:11 pm
by gemini06720
Duke something I have found out over the past years is that all the PHP code that is in use on a page should be processed before anything else - well, the PHP processor/compiler on the server has to get and process its data before that data can be used anywhere else.

It has also been my experience over the past months that the AJAX/JavaScript code should be processed as late as possible thus I now place (almost all of) the JavaScript at the bottom of the page or I use the 'defer="defer"' option when calling/loading the JavaScript - remember, the page has to be drawn with all its data/graphics before it can be updated, thus 'pushing' the download and start of the JavaScript on the user's computer for as late as possible - so far, it has been working well with the scripts/templates I have been working on.

Re: Monthly records page with PHP tags.

Posted: Tue 01 May 2012 10:39 pm
by mcrossley
Ray, you probably know, but the reason to put the scripts at the end of the page is because loading and parsing a script is a 'blocking' action on the browser - it pauses all other downloads and page rendering while it downloads and parses each script. There are some ways around this, but they involve tricks like the defer (which doesn't work in all browsers) and dynamic loading.