ltoto Posted October 19, 2006 Share Posted October 19, 2006 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 ise.gif the type = hotel , then show pages/hotel.php on Id=18if type= villa, then show pages/villa.php on Id=19if type=golf, then show pages/golf.php on Id=20any suggestions..... Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/ Share on other sites More sharing options...
Daniel0 Posted October 19, 2006 Share Posted October 19, 2006 Use the [url=http://php.net/control-structures.switch]switch[/url] control structure. Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111201 Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 and will that still switch between different Ids and pages though... Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111205 Share on other sites More sharing options...
Daniel0 Posted October 19, 2006 Share Posted October 19, 2006 I don't quite get what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111209 Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111214 Share on other sites More sharing options...
Daniel0 Posted October 19, 2006 Share Posted October 19, 2006 [code]<?phpswitch($row_rsHotem['hotelType']){ case 'Hotel': $row_rsPages['Id'] = 15; include "pages/country.php"; break; case default: // default action break;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111220 Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 it gives me this errorparse error, unexpected T_DEFAULT from this<?phpswitch($row_rsHotel['hotelType']){ case 'Hotel': $row_rsPages['Id'] = 15; include "pages/country.php"; break; case default: // default action break;}?> Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111255 Share on other sites More sharing options...
kenrbnsn Posted October 19, 2006 Share Posted October 19, 2006 It's not "case default", it's just "default".Ken Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111278 Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 <?phpswitch($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 Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111284 Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 <?phpswitch($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 Quote Link to comment https://forums.phpfreaks.com/topic/24437-if-statements-and-includes/#findComment-111316 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.