Page 2 of 2

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.