If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-03, 08:29
AJoëlD AJoëlD is offline
Registered User
 
Join Date: Dec 2003
Location: België
Posts: 1
Question Question

Hello i'm new to this board and also new to php and i have a question.
Here's the code i'm currently using :

<?
switch(strtolower($_GET['page']))
{
case "downloads":
switch(strtolower($_GET['sub'])) {
case "javascript": $page="downloads/java.php"; break;
case "php": $page="downloads/php.php"; break;
case "editors": $page="downloads/editors.php"; break;
case "templates": $page="downloads/templates.php"; break;
case "": $page="downloads/index.php";break;
}
break;

default: $page="pages/news.html";break;
}

include($page);
?>

My question is, how can i add another case so the link will look like this 'index.php?page=downloads&sub=javascript&fid=001'. I first thought of a case in a case but that didnt worked to well...If its possible could someone post an example of the code i need because i already said, i'm new to php.
Regards, Joël.
Reply With Quote
  #2 (permalink)  
Old 12-22-03, 11:04
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
PHP Code:
<?
switch(strtolower($_GET['page']))
{
    case 
"downloads"
    switch(
strtolower($_GET['sub'])) { 
        case 
"javascript"$page="downloads/java.php"; break; 
        case 
"php"$page="downloads/php.php"; break; 
        case 
"editors"$page="downloads/editors.php"; break; 
        case 
"templates"$page="downloads/templates.php"; break; 
        case 
""$page="downloads/index.php";break;
    } break;

    default: 
$page="pages/news.html";break;
}

if (isset(
$_GET['fid'])){
    
$fid=$_GET['fid'];
}else{
    
//default value if not set...
    
$fid=-1;
}

include(
$page);
?>
Don't you want to use require rather than include?

Oh yeah, please encase your code in [ php ] code here [ / php ] tags...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On