On Tue, 2007-12-04 at 10:25 +0000, sagr wrote:
Hi folks.
A very dumb question from a HTML / PHP beginner...
I have written a simple hit counter prog which I can access by running: http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?we...
I now want to integrate this into a HTML website page, so that this remote script "counter.php" is run and the result displayed on the HTML webpage each time the page is viewed.
I have created a simple HTML page: http://www.suffolk-ancestor-genealogy-research.co.uk/counters/count_page.htm...
which just consists of:
<HTML> <BODY> <script src="http://www.suffolk-ancestor-genealogy-research.co.uk/counters/counter.php?webpage=main"></script> </BODY> </HTML>
When I go to this count_page.html webpage the hit counter is incremented but the result is not displayed on the webpage (even though it's output is visible when I run the script counter.php directly).
How do I get the result from the remote script counter.php to display on my count_page.html page?
Hi sagr,
Your problem here is that the counter page is not generating valid ECMAscript (aka Javascript) to insert elements into the outer page. There are a couple of solutions that spring to mind:
[1] Counter page generates valid ECMAscript, eg: document.write(counter);
[2] Counter page generates vallid HTML, which you include in an IFRAME: <html><body>$counter</body></html> main page contains: <iframe src="...counter.php?page=main"/>
[3] Since it's PHP, just include the counter page in all other pages? This does mean you cannot have static HTML pages, everything must be a PHP.
HTH, Phil.