OLM3CA Posted September 14, 2006 Share Posted September 14, 2006 hi;My code is : [code] if($page=='SubmitNew') { include ('submit.php'); } if ($page=='Contact') { include ('contact.php'); } if ($page=='faq') { include ('faq.php'); } if ($page=='cat' && $category=='1') { $cat="shopping"; $m="14"; include ('outer.php'); } else { include('inner.php'); }[/code]My question is when I open the index.php, I see inner.php ,Its ok.But when I click on the link [code]?page=cat&category=1?page=faq , ?page=Contact [/code] I see the page [color=red]inner.php [/color] is still included to my page.In example:When I click on ?page=Contact I see the contact.php and below inner.phpI dont want that inner.php shown again. Quote Link to comment https://forums.phpfreaks.com/topic/20717-multiple-include/ Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 Rather using seperate if statements use and if/eseif/else statement.[code]<?phpif($page == 'SubmitNew'){ include 'submit.php';}elseif($page=='Contact'){ include 'contact.php';}elseif($page == 'faq'){ include 'faq.php';}elseif($page == 'cat'){ if($category == '1') { $cat = "shopping"; $m = "14"; include 'outer.php'; } else { include 'inner.php'; }}?>[/code]Or better option would be a switch/case statement:[code]<?phpswitch($page){ case 'SubmitNew': include 'submit.php'; break; case 'Contact': include 'contact.php'; break; case 'faq': include 'faq.php'; break; case 'cat': if($category == '1') { $cat = "shopping"; $m = "14"; include 'outer.php'; } else { include 'inner.php'; } break;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20717-multiple-include/#findComment-91657 Share on other sites More sharing options...
laide234 Posted September 14, 2006 Share Posted September 14, 2006 Here's another sample... might help[code]<?phpswitch ($page) { case 'submit' : $content = 'submit.php'; break; case 'contact' : $content = 'contact.php'; break; case 'faq' : $content = 'faq.php'; break; default : $content = 'submit.php'; }?><head></head><title></title><body <table> <tr> <td> <?php require_once 'header.php'; ?> </td> </tr> <tr> <td> <?php require_once $content; ?> </td> </tr> <tr> <td> <?php require_once 'footer.php'; ?> </td> </tr>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20717-multiple-include/#findComment-91667 Share on other sites More sharing options...
OLM3CA Posted September 14, 2006 Author Share Posted September 14, 2006 Thank you very much wildteen88 It works ;) Quote Link to comment https://forums.phpfreaks.com/topic/20717-multiple-include/#findComment-91677 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.