Page 1 of 1

Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 11:44 am
by jeffamm
:D What is best way to display more than one php app/script on the same page, say side by side? I could do it with iframes but those seem to have a variety of browser issues. I have bunch of php scripts that I want users to be able to see and use on the same page, but I'm a php noob and don't get how to do it. Sorry if the answer is obvious - I tried searching the forum and virtually every word I entered was disallowed by search function as too common. I'm trying to achieve the effect of a frame or iframe without the browser compatibility problems. 8O

thanks

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 12:18 pm
by Jade
iframes are okay but I'd say css is your best bet. Use div layers and just have them butt up next to each other.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 12:44 pm
by jeffamm
I don't understand. I'm familiar with CSS and <div> tags but how do I incorporate the output from different apps? I'm probably missing some basic php knowledge here, but I didn't think the apps could be built into one page. These are various scripts that I've purchased and that weren't written as part of one app.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 12:47 pm
by EverLearning
Use divs like Jade suggested, and populate them with AJAX calls.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 1:13 pm
by jeffamm
OK I'm not familiar with AJAX calls but from a little web searching I see things like cross-domain ajax calls using PHP - is this what you mean? Is there a good tutorial on ajax calls for what I want to do that you can recommend?

thanks

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 1:24 pm
by EverLearning
None that I can remember. Take a look at these

Ajax.Updater
Using the Ajax.Updater class

This is from Prototype Javascript framework.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 3:34 pm
by RobertGonzalez
Are you wanting to have executable php scripts that are independent of one another that can be interacted with by the user in the same browser window? Or do you just want to run multiple PHP scripts in the same window?

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 3:57 pm
by jeffamm
I'm not sure of the difference in the two choices so here's an example. I have a script installed in one folder of my hosting account that is for classified ads. I have a second script, totally separate from the first script, installed in a second folder, that looks up a telephone area code. I just want to have a single web page where the user can see and use the input/output screen of each script. I could create an html page with an two iframes, each one targeted on its respective script's home page. However iframes have browser compatibility issues that I want to avoid. Is there another/better way?

I hope this explains it - there's probably better/clearer language to explain what I'm trying to do, but I don't know the right terms.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 5:07 pm
by RobertGonzalez
No, you answered it pretty well. You are looking for asynchronous request/response handling, or in modern terminology, Ajax.

This means that you will have to code your page in a way that either tells the user that Javascript is required or you will have to code fall backs in case it is not.

There are boatloads of tutorials around on the use of the XMLHttpRequest object, Ajax and the like.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 5:12 pm
by jeffamm
Mr. Mod, thanks - which will work on more browsers - ajax/javascript or iframes?

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 5:36 pm
by RobertGonzalez
Javascript is probably going to work for you the most consistently but is not always guaranteed to be available. iFrames are just about supported everywhere, but some users have misgivings about them.

It is just about six of one and a half dozen of the other. Realistically I'd say go Ajax.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 5:42 pm
by John Cartwright
Everah wrote:. Realistically I'd say go Ajax.
In this instance I would not suggest using Ajax. For a beginner I would certainly suggest using frames in this case, since the OP may find himself a bit overwhelmed because it's likely going to entail some engineering to have the two app's play nice together in a single request. By using iframes we are treating them as separate requests (hence separate windows) and should work right away without any tweaking.

Very seldomly do I suggest using frames.. but they have their place and time.

Re: Displaying more than one php app on same page

Posted: Thu Apr 10, 2008 7:23 pm
by jeffamm
OK thanks for the advice guys. Am I correct that iframes are not supported by IE7 unless it is specifically activated by the user?