Jump to content
MakeWebGames

Multiple explore pages


moto
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);
}

?>
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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();
?>
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...