Map design, how?
Posted: Sun Jan 10, 2010 12:59 am
				
				I have been googling on how to make a map like this:

Now, some dude pasted code:
I would like to use the code, but I have no idea how it works.
I do not know why there are two codes either.
So, I wondered if someone could take some time to explain this valuable code to the rest of us?
Source: http://www.dreamincode.net/forums/showtopic76140.htm
			
Now, some dude pasted code:
Code: Select all
<?php
set_time_limit(10800);
    for($y=40;$y>=1;$y--)
    {
        for($x=1;$x<=40;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))
            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" title="('.$row['x'].'|'.$row['y'].')" style="float: left;margin: 0;padding:0;">';
        }
    }
?>Code: Select all
<?php
set_time_limit(10800);
    if(!$_POST)
    {
    for($y=40;$y>=34;$y--)
    {
        for($x=1;$x<=7;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))
            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" style="float: left;margin: 0;padding:0;">';
        }
    }
    echo '<div style="margin-top: 380px;">';
        echo '<form method="POST" action="hartamica.php">';
        echo 'x: <input type="text" style="width:50px;" name="x"><br>';
        echo 'y: <input type="text" style="width:50px;" name="y"><br>';
        echo '<input type="submit" name="submit" value="Cauta!"><br>';
        echo '</form>';
    echo '</div>';
    }
    else
    {
    $cx = $_POST['x'];
    $cy = $_POST['y'];
    $cy1 = $cy+3;
    $cx1 = $cx-3;
    $cy2 = $cy-3;
    $cx2 = $cx+3;
    for($y=$cy1;$y>=$cy2;$y--)
    {
        for($x=$cx1;$x<=$cx2;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))
            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" title="('.$row['x'].'|'.$row['y'].')" style="float: left;margin: 0;padding:0;">';
        }
    }
    echo '<div style="margin-top: 380px;">';
        echo '<form method="POST" action="hartamica.php">';
        echo 'x: <input type="text" style="width:50px;" name="x" value="'.$_POST['x'].'"><br>';
        echo 'y: <input type="text" style="width:50px;" name="y" value="'.$_POST['y'].'"><br>';
        echo '<input type="submit" name="submit" value="Cauta!"><br>';
        echo '</form>';
    echo '</div>';
    }
?>I do not know why there are two codes either.
So, I wondered if someone could take some time to explain this valuable code to the rest of us?
Source: http://www.dreamincode.net/forums/showtopic76140.htm
 Dunno if I can help you or not, but I'm looking into using something like this for my own project so I hope I can get something out of it.
 Dunno if I can help you or not, but I'm looking into using something like this for my own project so I hope I can get something out of it. but it is less then 50 lines of code
 but it is less then 50 lines of code