boionfire81 Posted March 30, 2016 Share Posted March 30, 2016 How can I display certain links based off of the city that the user is in? ie. if they are in city id 1,2,5 & 7 the link shows, but for all else the link does not show? Quote Link to comment Share on other sites More sharing options...
Zettieee Posted March 30, 2016 Share Posted March 30, 2016 if($var['id'] == 1) {echo "link here";} Quote Link to comment Share on other sites More sharing options...
sniko Posted March 30, 2016 Share Posted March 30, 2016 if($var['id'] == 1) {echo "link here";} Ugh. Since you have the $ir variable probably in the local scope. if( $ir['location'] == 1 ) { echo "<a href='#'>A link for location ID 1</a> <br />"; //Add more...? } if( $ir['location'] == 2 ) { echo "<a href='#'>A link for location ID 3</a> <br />"; //Add more...? } //Etc... Quote Link to comment Share on other sites More sharing options...
Zettieee Posted March 30, 2016 Share Posted March 30, 2016 if( $ir['location'] != "2") { echo "You cant access this area!"; echo "<a href='travel.php'> Move to location? </a>"; //footer shit exit; } place that in the file you want to limit access to. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted March 30, 2016 Share Posted March 30, 2016 there's a few ways it can be done using the if as stated above or switch http://codepad.org/psNITOdP Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted April 22, 2016 Author Share Posted April 22, 2016 Ok, links are working fine. I have if (in_array($ir['location'], array(105, 103, 90, 182, 39, 160, 40, 218, 131, 101))) { echo " But other pages that have multi functions are now confusing me. The above line again would work, but does it really need repeated EVERY function? That is going to really slow down the speed after awhile. Quote Link to comment 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.