This should be pretty simple,

We have written a script that calls certain information from our database then we use a simple echo to show the information on our other .php pages.

What we need to do is be able to show this same information on html pages as well.

We do understand we could convert the .html pages to php but at this moment that is not an option. So if any of you gurus out there could help us out and show us how to do this is would be appreciated.

In short we need a way to display dynamically created information on html pages.

Thank you.

Recommended Answers

All 5 Replies

Old-school way: use an iframe...

<iframe name="dbinfo" id="dbinfo"
    width="500" height="300"
    <h1>Yo Dude! Turn Frames Back On!</h1><p>(or go <a href="dbinfo.php">here</a>)</p>

New-fangled way: use a JavaScript XMLHttpRequest...

<div id="dbinfo">
    <h1>Dude! Turn JavaScript Back On!</h1>
    <p>(or go <a href="dbinfo.php">here</a>)</p>

<script type="text/javascript">
var request;
if ( window.XMLHttpRequest ) {
	request = new XMLHttpRequest();
// code for IE6, IE5
} else if ( window.ActiveXObject ) {
	request = new ActiveXObject("Microsoft.XMLHTTP");
} 'GET', 'dbinfo.php', false );
request.send( null );

document.getElementById('dbinfo').innerHTML = request.responseText;

If you decide to use the new-fangled way, you're going to need to double-check my code to make sure it's right. I didn't test it. If you wanna pay me, I'll do the page for you :icon_cheesygrin:

-- Ghodmode

Im not sure this is working as it is not rendering the code. How much would you charge for this?

You could add

AddType application/x-httpd-php .html

to your htaccess files. Then, html files will be parsed just the same as php files. So you can add php code to the html files.

Im not sure this is working as it is not rendering the code. How much would you charge for this?

That was just a joke. I never expected you to be interested in my offer :$ Although I do occasionally do web development work for money (Ghodmode on RentACoder), I'm not up to taking on another project right now, even a small one. Believe it or not, typing on these forums is how I relax when I'm not ready for more work.

I'm sorry if I got your hopes up.

Try to do it with the iframe method. Although that's generally discouraged in new web development, it is easier to implement. For the src attribute, try using the full URL instead of just the name of the file. For example, "" instead of just "dbinfo.php".

If you think that there might be something wrong with your iframe element's code, post just that block in a message here and I'll take a look.

-- Ghodmode

The javascript portion above worked well for what I need thank you for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.