Current location: Hot Scripts Forums » Programming Languages » PHP » Cases.


Cases.

Reply
  #1 (permalink)  
Old 09-02-05, 08:44 PM
Blaine0002 Blaine0002 is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Cases.

Im in the webteam for my school, and i have been assigned the language department. I thaught it would be cool to try and make the whole language departments page in one php file, this is what i have so far. It dosent work. Im thinking it has somthing to do with the overlapping braces. is there a correct way to do this? (DFLT is just a default main page for each language untill i get this working) (if theres a letter in caps before a word it means the language G=German ext.)
PHP Code:

<!-- 

LINKS GO BEFORE MID CONTENT GOES AFTER MID
START FUNCTIONS 
-->

<?
function Slinks()
{
echo 
'<a href="link.html">»&nbsp; Spanish</a>
<a href="link.html">»&nbsp; Links</a>
<a href="link.html">»&nbsp; Go</a>
<a href="link.html">»&nbsp; Here</a>'
;
?>
<?
function Flinks()
{
echo 
'<a href="link.html">»&nbsp; French</a>
<a href="link.html">»&nbsp; Links</a>
<a href="link.html">»&nbsp; Go</a>
<a href="link.html">»&nbsp; Here</a>'
;
?>
<?
function Glinks()
{
echo 
'<a href="link.html">»&nbsp; German</a>
<a href="link.html">»&nbsp; Links</a>
<a href="link.html">»&nbsp; Go</a>
<a href="link.html">»&nbsp; Here</a>'
;
?>
<?
function Jlinks()
{
echo 
'<a href="link.html">»&nbsp; Japanese</a>
<a href="link.html">»&nbsp; Links</a>
<a href="link.html">»&nbsp; Go</a>
<a href="link.html">»&nbsp; Here</a>'
;
?>

<?
function Dflt()
{
echo 
'<tr>
<td class="head2"> Default</td>
</tr></table><table width="100%" cellpadding="0" cellspacing="0"><tr><td class="outline2">
<p align="justify"> Default spanish page </p>
</td></tr></table>'
;
?>
<?
function Mid()

echo 
'</td></tr></table><br></TD><TD COLSPAN=2 valign="top" background="kkmlayout2_12.gif" width="501" height="29" style="background-repeat:no-repeat;padding-left:0px;padding-top:20px;padding-right:4px;"><table width="100%" cellpadding="0" cellspacing="0">';
 } 
?>

<!-- 
END FUNCTIONS
//START HEADER
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
        <title>MHS Language Department</title>
<style rel="stylesheet" type="text/css">
A:link
{ text-decoration: none;color:#6F4024;}
A:visited
{ text-decoration: none;color:#6F4024;}
A:active
{ text-decoration: none;color:#4A6239;}
A:hover
{ text-decoration: underline overline;color:#4A6239;background:#F9DFA9;
}
a.nav{color:#4F722D;text-align:center;cursor:hand;background-color:#F5EFC9;height:15;border:1 solid #323931;padding: 0 3px 0 3px;}
a.nav:link{color:#4F722D;cursor:hand;background-color:#F5EFC9;height:15;border:1 solid #323931;padding: 0 3px 0 3px;}
a.nav:visited{color:#4F722D;cursor:hand;background-color:#F5EFC9;height:15;border:1 solid #323931;padding: 0 3px 0 3px;}
a.nav:active{color:#FFFFFF;cursor:hand;background-color:#E4CC77;height:15;border:1 solid #323931;}
a.nav:hover{color:#FFFFFF;cursor:hand;background-color:#E4CC77;height:15;border:1 solid #323931;text-decoration:none;}
#navigation a 
{ display: block; width: 100%; height:15px; padding: 2px 2px 2px 10px; border: 1 solid #323931; background: #F7EDAF; text-decoration: none; } 
#navigation a:link, #navigation a:active, #navigation a:visited 
{color: #6F4024; border: 1 solid #323931; background: #F7EDAF; text-align:left;}
#navigation a:hover 
{ color: #4A6239; border: 1 solid #323931; background: #F5EFC9;} 
.head{font-weight:bold; color:#FFFFFF; padding: 3px 0px 0px 7px; text-align:left;text-transform:uppercase;height:26;background-image:url('kkmheader.gif');}
.head2{font-weight:bold; color:#FFFFFF; padding: 3px 0px 0px 7px; text-align:left;text-transform:uppercase;height:26;background-image:url('kkmheader2.gif');}
.outline{padding-top:2px;padding-bottom:2px;padding-left:2px;padding-right:2px;border-left:1 solid #323931;border-right:1 solid #323931;border-bottom:1 solid #323931;background-color:#C6CF3E;}
.outline2{padding-top:7px;padding-bottom:7px;padding-left:5px;padding-right:5px;border-left:1 solid #323931;border-right:1 solid #323931;border-bottom:1 solid #323931;background-color:#E7EC9D;}
body 
{ background: #E4DA77; 
background-repeat: repeat; 
background-attachment: scroll;
cursor:default;
font-family: verdana;
color: #647F60; 
letter-spacing: 1pt;
font-weight: normal;
font-size:12px;

scrollbar-face-color : #779E46; 
scrollbar-highlight-color : #DEEA6D; 
scrollbar-3dlight-color : #323931; 
scrollbar-shadow-color : #779E46; 
scrollbar-darkshadow-color : #323931;
scrollbar-track-color : #E4DA77; 
scrollbar-arrow-color : #E4C177; 
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0; 
padding-top: 0;
padding-bottom: 0;
padding-left: 0;
padding-right: 0; 
}
td
{ font-family:verdana;
font-size:12px;
letter-spacing: 0pt;
color: #647F60;
padding-left: 0cm; 
padding-right: 0cm;
padding-top: 0cm;
padding-bottom: 0cm;
padding: 0cm; 
padding: 0cm 0cm; }
</style>
</head>
<body>
<TABLE WIDTH=740 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
<tr>
<td background="kkmbg.gif" style="border-left:1 solid #000000;border-right:1 solid #000000;">
<TABLE WIDTH=740 BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
        <TD COLSPAN=5>
            <IMG SRC="kkmlayout2_01.gif" WIDTH=740 HEIGHT=33 ALT=""></TD>
    </TR>
    <TR>
        <TD>
            <IMG SRC="kkmlayout2_02.gif" WIDTH=17 HEIGHT=156 ALT=""></TD>
        <TD>
            <IMG SRC="kkmlayout2_03.jpg" WIDTH=708 HEIGHT=156 ALT=""></TD>

        <TD>
            <IMG SRC="kkmlayout2_06.gif" WIDTH=15 HEIGHT=156 ALT=""></TD>
    </TR>
    <TR>
        <TD>
            <IMG SRC="kkmlayout2_07.gif" WIDTH=17 HEIGHT=54 ALT=""></TD>
        <TD COLSPAN=3 background="kkmlayout2_08.gif" width="708" height="54" style="background-repeat:no-repeat;padding:12px 10px 10px 168px;">
<a href="index.php?language=French&fpages=index" class="nav">French</a>
<a href="index.php?language=German&gpages=index" class="nav">German</a>
<a href="index.php?language=Spanish&spages=index" class="nav">Spanish</a>
<a href="index.php?language=Japanese&jpages=index" class="nav">Japanese</a>

</TD>
        <TD>
            <IMG SRC="kkmlayout2_09.gif" WIDTH=15 HEIGHT=54 ALT=""></TD>
    </TR>
    <TR>
        <TD valign="top">
            <IMG SRC="kkmlayout2_10.gif" WIDTH=17 HEIGHT=29 ALT=""></TD>
        <TD valign="top" background="kkmlayout2_11.gif" width="207" height="29" style="background-repeat:no-repeat;padding-left:3px;padding-top:20px;padding-right:21px;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="head">
Navigation</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="outline" id="navigation">

<!-- 
// END HEADER
//START CONTENT
 //START MAIN
-->
<?
switch($_REQUEST['language'])
{
default:
?>
<a href="index.php?language=Japanese&jpages=index">»&nbsp; Japanese</a>
<a href="index.php?language=French&fpages=index">»&nbsp; French</a>
<a href="index.php?language=Spanish&spages=index">»&nbsp; Spanish</a>
<a href="index.php?language=German&gpages=index">»&nbsp; German</a>
<? Mid() ?>
<tr>
                <td class="head2"> Welcome!</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="outline2">
<p align="justify"> Welcome to the language department! select your destination. </p>
</td>
</tr>
</table>
<!-- 
//END MAIN
//START JAPANESE 
-->
<? case 'Japanese'
Jlinks();
Mid(); ?>
<? 
switch($_REQUEST['jpages'])

?>
<? 
case 'index'?>
<? Dflt
(); ?>
<? 
?>
<!-- 
//END JAPANESE
//START FRENCH 
-->
<? case 'French'
Flinks();
Mid(); ?>
<? 
switch($_REQUEST['fpages'])
?>
<? 
case 'index'?>
<? Dflt
(); ?>
<? 
?>
<!-- 
//END JAPANESE
//START FRENCH 
-->
<? case 'Spanish'
Slinks();
Mid(); ?>
<? 
switch($_REQUEST['spages'])
?>
<? 
case 'index'?>
<? Dflt
(); ?>
<? 
?>
<!-- 
//END JAPANESE
//START FRENCH 
-->
<? case 'German':
Glinks();
Mid(); ?>
<? 
switch($_REQUEST['gpages'])
?>
<? 
case 'index'?>
<? Dflt
(); ?>
<? 

 }
?>
<!-- 
// END GERMAN
// END CONTENT
//START FOOTER 
-->
<br>
          </TD>
        <TD valign="top">
            <IMG SRC="kkmlayout2_13.gif" WIDTH=15 HEIGHT=29 ALT=""></TD>
    </TR>
<tr>
          <td colspan="5" background="kkmlayout2_14.gif" width="740" height="58" style="background-repeat:no-repeat;padding:43px 0px 0px 7px;"> 
            <font size="1"> <b>// French // Spanish // German // Japanese</b> 
            </font> </td>
</tr>
</TABLE>
</td>
</tr>
</table>
</BODY>
</HTML>

Last edited by Blaine0002; 09-02-05 at 08:46 PM.
Reply With Quote
  #2 (permalink)  
Old 09-03-05, 04:20 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
when using 'case:' you should place 'break;' after every case:
f.e:
PHP Code:

switch($foo):

  case 
1:
    echo 
"The Value = 1";
  break;
  case 
2:
   echo 
"The value = 2";
  break;
endswitch; 
Why are you using $_REQUEST[] (i don't why it is used for), i think you'ld better use $_GET[] as you send data through a link (<a href="index.php?language=Japanese&jpages=index">). To get the info, you should use $_GET['language'] and $_GET['jpages'], but forgive me if i'm wrong

Let me know if it works
Greetz,

UnrealEd

Last edited by UnrealEd; 09-03-05 at 04:26 AM.
Reply With Quote
  #3 (permalink)  
Old 09-03-05, 12:36 PM
Blaine0002 Blaine0002 is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
ah! it works! thanks a bunch!
Reply With Quote
Reply

Bookmarks


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
test cases organization substance Visual Basic 0 11-18-04 02:04 AM
login with db check using cases digital4twenty ASP 2 05-13-04 07:35 AM


All times are GMT -5. The time now is 06:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.