jbingman Posted December 30, 2007 Share Posted December 30, 2007 im trying to put in content but restrict it to certain pages. The index page, the about us page, and the contact page. I use: if($_GET['page'] == 'index' || 'about' || 'contact') { //content here }elseif($_GET['page'] == 'videos') { //content here }elseif($_GET['page'] == 'graphics') { //content here }elseif($_GET['page'] == 'web') { //content here but that doesnt work. it puts that content in ALL the pages. It works if i take out the other 2 'or' statements in the first if. (the "|| 'about' || 'contact'") Does anyone know why? or how to make that work? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/83772-solved-or-condition-in-if-statement/ Share on other sites More sharing options...
kenrbnsn Posted December 30, 2007 Share Posted December 30, 2007 You need to use <?php if($_GET['page'] == 'index' || $_GET['page'] == 'about' || $_GET['page'] == 'contact') { ?> But I would use a switch statement: <?php if (isset($_GET['page'])) switch ($_GET['page']) { case 'index': case 'about': case 'contact': // // code // break; case 'videos': // // code // break; case 'graphics': // // code // break; case 'web': // // code // break; default: // // default code // break; } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/83772-solved-or-condition-in-if-statement/#findComment-426216 Share on other sites More sharing options...
jbingman Posted December 30, 2007 Author Share Posted December 30, 2007 oh ok that makes sense. thank you. Quote Link to comment https://forums.phpfreaks.com/topic/83772-solved-or-condition-in-if-statement/#findComment-426222 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.