Reply
PHP Switch ~ Pages
Old 03-01-2007, 01:54 PM PHP Switch ~ Pages
Red_X_'s Avatar
Skilled Talker

Posts: 79
Location: USA
Basically I got a few pages:

Index.php
Network.php
Order.php
contact.php

I want those pages to use the get function throughout the page.

Example:

http://www.mysite.com/index.php?=Network (and have the network id be the network.php page) so the page would just jump off the index. More of a personal thing.

Thanks:

X
__________________
>> Higher a poor college student. PM me :). PHP/MySQL <<
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
When You Register, These Ads Go Away!
     
Old 03-01-2007, 02:13 PM Re: PHP Switch ~ Pages
Insensus's Avatar
Ultra Talker

Posts: 275
Name: Mark Stegeman
Location: Netherlands, Europe
You mean jump to that page or include it?

Jump:
PHP Code:
<?php
if(isset($_GET['id'])){
Header('Location:'.$_GET['id'].'.php');
}else{
// Normal index page
}
?>
Include:
PHP Code:
<?php
if(isset($_GET['id'])){
include_once(
$_GET['id'].'.php');
}
?>
Note:
Linking goes like this:
Index.php?id=Network
!Case sensitive!

Regards,
Insensus
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 03-05-2007, 09:22 AM Re: PHP Switch ~ Pages
Red_X_'s Avatar
Skilled Talker

Posts: 79
Location: USA
Perhaps a example? As i've tested this code, and it doesn't seem to work. I just basically like I said above to have the index, jump to those pages. But keep my header, and footer information. without having to reload them.

So would the switch be layed out something like this?

PHP Code:
switch ($page):
case 
0:
   echo 
"?page=network.php";
   break;
case 
1:
   echo 
"?page=contact.php";
   break;
case 
2:
   echo 
"?page=order.php";
   break;
default:
   echo 
"index.php";
endswitch; 
__________________
>> Higher a poor college student. PM me :). PHP/MySQL <<
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Old 03-05-2007, 09:32 AM Re: PHP Switch ~ Pages
Insensus's Avatar
Ultra Talker

Posts: 275
Name: Mark Stegeman
Location: Netherlands, Europe
Uhm. No.

I'll state you a small example:

PHP Code:
<html>
<head>
<title>Test page</title>
</head>
<body>
<div id="Header">Your header goes here</div>
<div id="Content">
<?php
switch($_GET['page']){
case 
1:
include_once(
'news.php');
break;
case 
2:
include_once(
'galleries.php');
break;
case 
3:
include_once(
'links.php');
break;
default:
include_once(
'home.php');
break;
}
?>
</div>
</div id="Footer">Your footer goes here</div>
</body>
</html>
Now you can link to:
'News': 'index.php?page=1'
'Galleries': 'index.php?page=2'
'Links': 'index.php?page=3'

If no page is supplied, you get the 'Home' page.

Regards,
Insensus
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 03-05-2007, 11:38 AM Re: PHP Switch ~ Pages
memberpro's Avatar
Super Talker

Posts: 143
When you supply variables to a webpage via the GET method.. you are reloading the entire page.

Say you click on a link with an address of 'index.php?index=page2.php' ... the index.php page still completely reloads, but will now just include a different file for the content.

You state in your post that you want to keep the header and footer information the same... Am I understanding you correctly, or is the solution provided what you are looking for?
__________________
Membership Mastery Videos - step-by-step learn how to design, create and install your own website in hours...not days. Web Site Design was never so easy.
memberpro is offline
Reply With Quote
View Public Profile
 
Old 03-05-2007, 02:27 PM Re: PHP Switch ~ Pages
Red_X_'s Avatar
Skilled Talker

Posts: 79
Location: USA
Quote:
Originally Posted by memberpro View Post
When you supply variables to a webpage via the GET method.. you are reloading the entire page.

Say you click on a link with an address of 'index.php?index=page2.php' ... the index.php page still completely reloads, but will now just include a different file for the content.

You state in your post that you want to keep the header and footer information the same... Am I understanding you correctly, or is the solution provided what you are looking for?
Basically my page is layed out like such. Top(header)right(links)bottom(footer)

The only thing I want to change is the left side were my information is stored on each relaod. :P I forgot the links part above.
__________________
>> Higher a poor college student. PM me :). PHP/MySQL <<
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Old 03-05-2007, 02:29 PM Re: PHP Switch ~ Pages
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Then you should use frames or AJAX to change only a part of a page.
__________________
Seo Link Directory | Kurs C++ | Forum C++
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-05-2007, 04:16 PM Re: PHP Switch ~ Pages
memberpro's Avatar
Super Talker

Posts: 143
I agree...Use AJAX/javascript along with an iframe to do what you are looking for.
__________________
Membership Mastery Videos - step-by-step learn how to design, create and install your own website in hours...not days. Web Site Design was never so easy.
memberpro is offline
Reply With Quote
View Public Profile
 
Old 03-07-2007, 08:28 AM Re: PHP Switch ~ Pages
Red_X_'s Avatar
Skilled Talker

Posts: 79
Location: USA
Haha i'm to lazy to implement some JS or AJAX. So i'll just stick with the other way, to just have the page reload. But thanks for the idea, i'll keep it in mind.
__________________
>> Higher a poor college student. PM me :). PHP/MySQL <<
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
Reply     « Reply to PHP Switch ~ Pages
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16220 seconds with 13 queries