PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 31st, 2003, 07:20 PM
wastedbreath wastedbreath is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: BC, Canada
Posts: 35 wastedbreath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to wastedbreath
PHP navigation

Hey guys, just a quick question.

On sites with URLs such as:
core.php?s=profile&user=him

how do I get the second part user=him ?

I use this code to get the first bit.
Code:
    <?php
     switch($s)   {

      case "home":
       include("blog.php");
      break;

      case "port":
       include("port.php");
      break;

      case "link":
       include("link.php");
      break;

      default:
       include("blog.php");
      break;
     }
    ?>


Thanks for any help.

I figure I need to add another switch, but not sure where. Would you like my main page code?
__________________
My Site in the works

Last edited by wastedbreath : August 31st, 2003 at 10:07 PM.

Reply With Quote
  #2  
Old August 31st, 2003, 07:53 PM
wastedbreath wastedbreath is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: BC, Canada
Posts: 35 wastedbreath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to wastedbreath
Ok, here it is better explained, or so the other forum I postted at thought

On my main page I have these links:
-home
-portfolio
-links

When I click Portfolio, the URL in the address bar will become:
main.php?s=port

And on the Portfolio page the secondary menu will load:
-photo manip
-photography
-experimental
-traditional
-php
-c++

And I want the URL to be:
main.php?s=port&ss=mainp

How do I get the &ss=manip?

Reply With Quote
  #3  
Old August 31st, 2003, 09:51 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Let us first resolve your first issue.
I notice you have your default case first in your switch statement. Your default case should be the last case statement.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old August 31st, 2003, 10:07 PM
wastedbreath wastedbreath is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: BC, Canada
Posts: 35 wastedbreath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to wastedbreath
Ok. Fixed.

Reply With Quote
  #5  
Old August 31st, 2003, 11:25 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Next think to do is go ahead and nest another switch statement in there.

It is ok to nest a switch statement.

Optionally, you can go another route.

PHP Code:
function showPage($file)
{
  
/* As $file is an array, we should join the elements into a string */
  
$filename is_array($file) ? join('_'$file) : $file;

  
/* add a php extension to filename */
  
$filename .= ".php";

  
/* if file does not exist include some default file */
  
if (!@include($filename)) {
    exit(require(
'page_not_found.php'));
  ) 

  return 
true;

}

/* to use this function
Lets say your url is: main.php?s=port&ss=mainp
The above function would then be looking for a file called:
port_mainp.php
*/
$pageArray = array($_GET['s'], $_GET['ss']);
if (
showPage($pageArray)) {
 
// action you want to take if page is loaded
} else {
 
// action you want to take if page is not found



This code is not tested but you should be able to work out any minor syntax / logic errors.

Reply With Quote
  #6  
Old August 31st, 2003, 11:55 PM
wastedbreath wastedbreath is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: BC, Canada
Posts: 35 wastedbreath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to wastedbreath
Excellent. Thanks man! I think I'll try nesting a switch statement, if that doesn't work, I'll try your code, and if *that* doesn't work, all hell will break lose on my monitor

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP navigation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT