This is a discussion on "Including php in html" within the PHP Forum section. This forum, and the thread "Including php in html are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Including php in html
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Including php in html
Hi,
I have a simple counter file written in php (just increments a value stored in a text file) when parsed all it displays is '35' or whatever the visitor number is. I want to include this into a html homepage (I don't really want to change index.htm to index.php) so im wondering if i could use some html/javascript that would run counter.php so i see the output. Something like this <br>You are visitor number <b>(Code_for_including_counter.php)</b> Welcome</br> Is this possible as I can't find a way to do it though i don't see why not. I suppose it would be possible using an iframe but i didnt want to do that either |
|
|
|
|||
|
Re: Including php in html
I use
|
|
|||
|
Re: Including php in html
Hi, no they wouldnt let me do that,
I found that using this
i.e. <br>Number of visitors since January: <script url"./counter.php"></script> doesn't output the number (I have the echo statement so it outputs the number if i just run counter.php as normal) but nothing when it runs from the html Last edited by djme; Jan 21st, 2006 at 22:49. |
|
|||
|
Re: Including php in html
then create index.php and use that. for your index.html file, if you are worried about people having it bookmarked or whatever, do a redirect to your php file.
|
|
|||
|
Re: Including php in html
yeh but i didnt really want to do that if theres another way to do it - it seems pointless for such little code
|
|
|||
|
Re: Including php in html
I just thought as im accessing the php and its carry out its task, all i need to do is import the data from the text file
|
|
|||
|
Re: Including php in html
Hey man you can do it actually! And you can do it quite easily. This little article has helped me do things sort of what your asking for many times. Its a minature implimentation of the AJAX, but without all the bells and whistles. You can run php scripts on the fly by accessing them through js.
http://www.devshed.com/c/a/PHP/PHP-a...Your-Resources |
|
|||
|
Re: Including php in html
I'm assuming you are familiar with JavaScript, what you could make your counter.php into a JavaScript file, where it puts the number of visitors into a variable, include the script in the header of your html file, then call the variable with a short JavaScript. It should be really easy.
|
![]() |
| Tags |
| including, php, html |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Including a File | Corey Bryant | ASP.NET Forum | 8 | Mar 12th, 2008 03:27 |
| including inside a function | CloudedVision | PHP Forum | 2 | Feb 11th, 2008 00:13 |
| Webpage calender including clock | satimis | Web Page Design | 0 | Dec 28th, 2007 05:25 |
| 3 CSS Issues, including a float problem in IE6 | TheoUK | Web Page Design | 1 | Jul 3rd, 2007 23:56 |