moto Posted August 25, 2008 Share Posted August 25, 2008 I have been trying very hard to get my game to display a different explore page for each city. I looked through all the posts and tried asking others for help already. i know a little about php / html and my methods havn't be very successful. Would any of u guys have an idea that might work ? Quote Link to comment Share on other sites More sharing options...
radio_active Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages Well down to basics, you create different .php pages for each city with a block if your from another city so you cant access every explore page... That, i believe, would be the easiest way to do so otherwise you would have to add alot of code to one file! ( which is also very possibly to do) Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages if ($ir['location'] == 1) { echo "City one links"; } else if ($ir['location'] == 2) { echo "City two links"; } // and so on... that should help you Quote Link to comment Share on other sites More sharing options...
moto Posted August 25, 2008 Author Share Posted August 25, 2008 Re: Multiple explore pages Thanks Zero I was on the right track than at least . I figure i could do with if /else but wasn't sure of how to deal with table issue .....seperate pages makes it a heck of lot more plasiable Quote Link to comment Share on other sites More sharing options...
POG1 Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages There are many ways to do this, here is how i would do it... First off make some new directory's if you don't already have them. Create a "inc" dir in the game root. Then inside inc make a "Citys" dir, It's inside this where you will make the php files for each different city. explore.php <?php include('globals.php'); swich($ir['city']) { case '1': include('inc/citys/city1.php'); break; case '2': include('inc/citys/city2.php'); break; // The case number is the city id they are in // Add more for the city ids } ?> haven't tested it but it probably will work Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages why waste space... just use one file keep it simple <?php require "globals.php"; if ($ir['location'] == 1) { $link1="index.php"; $name1="Home"; $link2="explore.php"; $name2="Explore"; $link3="bank.php"; $name3="Bank"; $link4="viewuser.php?u={$userid}"; $name4="My profile"; } else if ($ir['location'] == 2) { $link1="index.php"; $name1="Home"; $link2="monorail.php"; $name2="Travel"; $link3="cmarket.php"; $name3="Crystal Market"; $link4="fedjail.php"; $name4="Federal Jail"; } // and so on... echo " <table width=80% border=1> <tr> <th>Example</th> </tr>"; if ($link1 && $name1) { echo "<tr><td>[url='{$link1}']{$name1}[/url]</td></tr>"; } else if($link2 && $name2) { echo "<tr><td>[url='{$link2}']{$name2}[/url]</td></tr>"; } else if($link3 && $name3) { echo "<tr><td>[url='{$link3}']{$name3}[/url]</td></tr>"; } else if($link4 && $name4) { echo "<tr><td>[url='{$link4}']{$name4}[/url]</td></tr>"; } echo " </table> "; $h->endpage(); ?> i have no clue if that will work but probably will i'm just kinda bored lol Quote Link to comment Share on other sites More sharing options...
Spudinski Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages why waste space... just use one file keep it simple <?php require "globals.php"; if ($ir['location'] == 1) { $link1="index.php"; $name1="Home"; $link2="explore.php"; $name2="Explore"; $link3="bank.php"; $name3="Bank"; $link4="viewuser.php?u={$userid}"; $name4="My profile"; } else if ($ir['location'] == 2) { $link1="index.php"; $name1="Home"; $link2="monorail.php"; $name2="Travel"; $link3="cmarket.php"; $name3="Crystal Market"; $link4="fedjail.php"; $name4="Federal Jail"; } // and so on... echo " <table width=80% border=1> <tr> <th>Example</th> </tr>"; if ($link1 && $name1) { echo "<tr><td>[url='{$link1}']{$name1}[/url]</td></tr>"; } else if($link2 && $name2) { echo "<tr><td>[url='{$link2}']{$name2}[/url]</td></tr>"; } else if($link3 && $name3) { echo "<tr><td>[url='{$link3}']{$name3}[/url]</td></tr>"; } else if($link4 && $name4) { echo "<tr><td>[url='{$link4}']{$name4}[/url]</td></tr>"; } echo " </table> "; $h->endpage(); ?> i have no clue if that will work but probably will i'm just kinda bored lol ...and that's why arrays were created. Using separate files would make it easier to modifiy the different pages, but it could hold a security risk if it is placed in web root(htdocs/www/public_html) and not protected by direct access. Here is an example. <?php require('globals.php'); $pages = array( 0 => false, 1 => 'new york', 2 => 'london', 3 => 'tokio', 4 => 'johannesburg', 5 => 'venice' ); $absolute_path = '/home/user/includes/cities/' . strtolower(str_replace(' ', '_', $pages[intval($ir['location'])])) . '.php'; if ($pages[intval($ir['location'])] == false || !file_exists($absolute_path)) { // we assume invalid entry ... or hacking attempt(?) echo 'You do not have permission to be here, you will automatically be transfered to the first city.'; mysql_query('UPDATE `users` SET `location` = 1 WHERE `userid` = ' . $userid); } else { echo ' <h3>Welcome to ' . ucwords($pages[intval($ir['location'])]) . '!</h3></p>'; include($absolute_path); } ?> Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages i still prefer mine Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages i would still go with pog-one's example, or just use function's & switch. Quote Link to comment Share on other sites More sharing options...
POG1 Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages why waste space... just use one file keep it simple i have no clue if that will work but probably will i'm just kinda bored lol My example was very simple. i would still go with pog-one's example, or just use function's & switch. You could also add the functions in the page and call a function instead of include the filed :) Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 25, 2008 Share Posted August 25, 2008 Re: Multiple explore pages Exactly what i ment pog-one <?php include("globals.php"); function databst() { globals $db,$ir,$set; } switch($ir['location']) { case '1': city_one(); break; case '2': city_two(); break; } function city_one() { databst(); echo 'blah'; } function city_two() { databst(); echo 'blah'; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 26, 2008 Share Posted August 26, 2008 Re: Multiple explore pages Nice :wink: Quote Link to comment Share on other sites More sharing options...
moto Posted August 27, 2008 Author Share Posted August 27, 2008 Re: Multiple explore pages I got it working guys thanks for your suggestions. Quote Link to comment Share on other sites More sharing options...
morgan1122 Posted December 29, 2010 Share Posted December 29, 2010 Cheers for that now i have installed it myself with a few edits :) 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.