Jump to content

Recommended Posts

so i have this
[code]
<?php
switch($row_rsHotel['hotelType'])
{
case 'Hotel':
if(@$_GET['Id']== "15")
include "pages/country.php";
break;

case 'Villa':
if(@$_GET['Id']== "3")
include "pages/country.php";
break;

case 'Golf':
if(@$_GET['Id']== "2")
include "pages/country.php";
break;


default:
// default action
break;
}
?>
[/code]
the first one works, but the last two dont, any suggestions...
Link to comment
https://forums.phpfreaks.com/topic/24518-php-switch-control-structuresolved/
Share on other sites

[code]<?php
switch($row_rsHotel['hotelType'])
{
case 'Hotel':
if($row_rsPages['Id']== "15")
include "pages/country.php";
break;

case 'Villa':
if($row_rsPages['Id']== "3")
include "pages/country_villa.php";
break;

case 'Golf':
if($row_rsPages['Id']== "2")
include "pages/country_golf.php";
break;


default:
// default action
break;
}
?>[/code]

i slightly changed it to this now, which is still not working
You said that the first one was working correctly right?

Please post the method that you come up with the $row_rsHotel['hotelType']

Now this is how I like to use the switch statement.

[code]
<?php

function getPage($page) {
    switch($page) {
        case "something":
            //some code here
        break;
        case "something_else":
          //some more code here
        break;
        default:
            //something else
        break;
    }
}

getPage($row_rsHotel['hotelType']);
?>
[/code]

Good Luck,
Tom
sorry for the double post, i seem to have found what id happening

if I change the hotel type on the first hotel e.g :

If Id=1 and the type is golf, it will take everything onto the golf pages, e.g all other ideas

and it does this if a change it to hotel, or villa aswell.....
I may have something wrong here, but I always thought that the 'switch' statement was an alternative way of writing 'if' statements?  If this is a case, then why combine both in the same piece of code...

[quote author=ltoto link=topic=112094.msg454870#msg454870 date=1161339827]
[code]<?php
switch($row_rsHotel['hotelType'])
{
case 'Hotel':
if($row_rsPages['Id']== "15")
[/code]
[/quote]

Regards
Huggie
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.