There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: PHP Site Navigation


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Bobathome's Avatar
Member with 41 posts.
 
Join Date: Aug 2007
Experience: Intermediate
24-Jan-2008, 06:45 PM #1
Solved: PHP Site Navigation
Hey guys,

Ive been working up another website, and thought I would try too add the "?page=2&id=4" type thing. After doing some googling, I haven't come up with much luck. Does any know any good tutorials for this for a comrade with low PHP knowledge?

Thanks.
eric_sc's Avatar
Computer Specs
Member with 42 posts.
 
Join Date: Sep 2007
Experience: Intermediate
24-Jan-2008, 07:50 PM #2
try this tutorial

http://www.developertutorials.com/tu...816/page1.html

maybe it will help you out. i'm in the same boat, "a comrade with low PHP knowledge" ha
Anthony:-P's Avatar
Computer Specs
Senior Member with 448 posts.
 
Join Date: Nov 2006
Location: UK
Experience: Between Intermediate and
25-Jan-2008, 08:17 AM #3
Hi Both,

A good way to do this would be to have links as you say (index.php?page=about)

Then basically, you create index.php (the template) and then where the content should go you put:

PHP Code:
<?php
if(isset($_GET['page']))
{
$p $_GET['page'];
if(
file_exists("pages/$p.php"))
        include(
"pages/$p.php");
else
        include(
"pages/home.php");
}
else
        include(
"pages/home.php");
Then you put all your pages in a directory called "pages" and then when you go to the URL index.php?page=about it checks to see if it exists in the pages directory.

If it does, then it displays it. If not then it displays home.php (the main page).

That up there is a basic version of it. Of course you'll want to put some protection in there so that they can't screw you over i.e index.php?page=../index (will include the index file in itself...and then in itself again :S) (been there...done that... never again!)

Regards,
Anthony
__________________
Currently training at geekstogo!
If your thread is solved, please mark as solved from the 'Thread Tools' menu.
My computer beat me at chess, however it was no match for me at kick boxing!

Last edited by Anthony:-P : 25-Jan-2008 08:18 AM. Reason: Forgot an else statement :-)
Bobathome's Avatar
Member with 41 posts.
 
Join Date: Aug 2007
Experience: Intermediate
25-Jan-2008, 02:10 PM #4
Thanks for both reply's. I have the basic concept down now . But, I still have one question on how to set it up? For example say I have <a href="about.php(or .html)">About</a>. How would I apply the PHP so when they click it, it'll be like ?page=about.

Or do I just place the PHP code near the top of my page, and it'll automatically do that for every link?

*edit* Or would I just do something like <a href="index.php?page=about">About</a>?

Sorry for the confusion

Last edited by Bobathome : 25-Jan-2008 02:12 PM. Reason: Something else
Anthony:-P's Avatar
Computer Specs
Senior Member with 448 posts.
 
Join Date: Nov 2006
Location: UK
Experience: Between Intermediate and
25-Jan-2008, 03:00 PM #5
Hi,

You'd just do it as normal: <a href='index.php?page=whatever'>SOME TEXT</a>

Regards,
Anthony.
bearqst's Avatar
Senior Member with 161 posts.
 
Join Date: May 2004
Location: Interior Alaska
Experience: Advanced
27-Jan-2008, 01:44 PM #6
Another good site for php help

http://www.codewalkers.com/
Bobathome's Avatar
Member with 41 posts.
 
Join Date: Aug 2007
Experience: Intermediate
27-Jan-2008, 09:13 PM #7
Thanks to all who helped!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:07 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.