|
|
|
|
![]() ![]() |
Sep 12 2005, 02:58 PM
Post
#1
|
|
|
Proud to be hosted ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 993 Joined: 11-July 04 From: NL Member No.: 75 |
I've been trying to get my website urls to work with an variable in the url to navigate. The script I use is:
CODE <?php switch ($page) { case "home": include home.php; break; case "members": include members.php; break; case "diplomacy": include diplomacy.php; break; case "scrims": include scrims.php; break; case "forums": include forums.php; break; default: include home.php; break; } ;?> And I specify the hyperlinks as index.php?page=home etc But it doesnt work, am I doing something rong in this script? |
|
|
|
Sep 12 2005, 03:05 PM
Post
#2
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,227 Joined: 11-February 05 From: Heaven Member No.: 3,709 |
Don't understand half the script, but the first thing I would do is put speech marks or apostrophes round the include statements. Eg:
CODE include bla.php; Becomes..... CODE include "bla.php"; What kind of error do you get? |
|
|
|
Sep 12 2005, 08:10 PM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 362 Joined: 25-August 05 Member No.: 11,104 |
i use a little bit of php and lots of html, html is so much easier for stuff. so i use html for mostly all of the stuff including the navigation. i know hardly anything about php i might learn it one day but not sure. Is using php better or something?
This post has been edited by BuffaloHELP: Sep 12 2005, 08:36 PM |
|
|
|
Sep 12 2005, 08:57 PM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 339 Joined: 2-December 04 From: Atlanta, GA Member No.: 2,516 |
Ah! Exactly what I was trying to do a few weeks ago-
You have to use the 'get' function to get the URL in the address bar first- I don't remember how to do it exactly, but browse the PHP programming section. That's the 'crucial' part you're missing. But on the other hand, good work with the cases- just won't work here Panda |
|
|
|
Sep 13 2005, 02:42 AM
Post
#5
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 117 Joined: 3-May 05 From: A Canadian South of the 49th Parallel Member No.: 6,544 |
Try something like this:
CODE <?php switch ($_GET['page']) { case "members": include 'members.php'; break; case "diplomacy": include 'diplomacy.php'; break; case "scrims": include 'scrims.php'; break; case "forums": include 'forums.php'; break; default: include 'home.php'; break; } ?> I hope that helps! |
|
|
|
Sep 13 2005, 02:46 AM
Post
#6
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 117 Joined: 3-May 05 From: A Canadian South of the 49th Parallel Member No.: 6,544 |
Omg, sorry, I overlooked one more thing, the "include" part is actually a function, so it should have the () brackets.. Also, you should use the require() or require_once() functions when doing what you're doing, something like this:
CODE require( 'members.php' ); |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th October 2008 - 01:46 AM |