Log in

View Full Version : Displaying different pages while staying on index..



jcord04
08-14-2010, 12:36 AM
Hi Peeps,

I am very new to php and need some help please!! :)

I would like to know if there is anyway of using php to display different content (text pictures etc) while keeping the header??

I have a page that uses flash for the header and need to load new pages underneath this while not refreshing the flash file! :confused:

Thanks! :)

azoomer
08-14-2010, 12:51 AM
I don't know of a way to do it with php, but you can do it with ajax. Here is a demo (http://azoomer.com/davelf/) I made a while ago. This was made in order to have some music playing while changing content, but the musicplayer is actually flash ( swf file).

jcord04
08-14-2010, 12:20 PM
Thank you!!! :):):):):)

djr33
08-14-2010, 04:02 PM
Yes, this can be done using PHP.

The most basic method is using the function called include() (http://php.net/manual/en/function.include.php).

Of course it can become more complex depending on your situation, but it is a very useful tool.

Once it becomes very complex, this is called templating and may require a database, etc.

In your situation, you should be able to create a page called "header.php" with ONLY the html code for the flash-- no extra tags, no <html> or <head> tags, just the content for flash. Then on any page you want that header, use:
<?php include('path/to/header.php'); ?>

Note that your pages must use the .php extension to execute this PHP code-- your header page, unless it has other PHP, does not need to be .php-- it could be .htm or another extension if you want.

jcord04
08-16-2010, 10:24 PM
Thanks djr33

This works great!!! :-D although i need it to include (index.php?x=browse&category=3) which doesnt seem to work!! :-S !!

Please help!!

Thankyou!! :-P

jcord04
08-17-2010, 12:12 AM
hey just for newbies like myself!! :-P

i found a solution to passing queries using include!

<?php
$_GET['x'] = 'browse';
$_GET['category'] = '6';
include 'index.php';
?>


example: index.php?x=browse&category=6

:-D :-P

djr33
08-17-2010, 05:04 PM
Yes, that can work. But why do you need to use "GET" variables like that? Once you're using PHP, there are more direct ways to handle it. Unless you're trying to include pages with that format from another piece of software such as a forum, I suppose...

include() will use a file, not a URL. It can be a full URL (I don't know about GET variables) but only if your server is setup to allow external files. Because of this, the data after the ? is irrelevant.