Jump to content


Photo

if statements and includes


  • Please log in to reply
9 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 12:27 PM

what i want to do is i have an option in the SQl table called hotel type, where the type can either be hotel, villa or golf,

what i want it to do is

e.g

if the type = hotel , then show pages/hotel.php on Id=18

if type= villa, then show pages/villa.php on Id=19

if type=golf, then show pages/golf.php on Id=20

any suggestions.....

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 12:40 PM

Use the switch control structure.

#3 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 12:49 PM

and will that still switch between different Ids and pages though...

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 12:52 PM

I don't quite get what you mean.

#5 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 01:01 PM

maybe it would be easier to show u what i had written:

<?
if ($row_rsHotel['hotelType'] == "Hotel" ){
$row_rsPages['Id']== "15")
include "pages/country.php";
}
?>

which obviously is wrong

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 01:08 PM

<?php
switch($row_rsHotem['hotelType'])
{
	case 'Hotel':
		$row_rsPages['Id'] = 15;
		include "pages/country.php";
		break;
	case default:
		// default action
		break;
}
?>


#7 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 01:52 PM

it gives me this error

parse error, unexpected T_DEFAULT

from this

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

#8 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 October 2006 - 02:17 PM

It's not "case default", it's just "default".

Ken

#9 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 02:22 PM

<?php
switch($row_rsHotel['hotelType'])
{
case 'Hotel':
if(@$_GET['Id']== "15")
include "pages/country.php";
break;
default:
// default action
break;
}
?>

i changed it to now and it works, i assumue i just do that for the other two bits

#10 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 October 2006 - 02:52 PM

<?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;


default:
// default action
break;
}
?>


i tried this but it did not work..... any suggestions as to what i should do, i got no error




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users