map_viewer.php
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include_once('dbconnect.php');
//Map size
if(isset($_GET['x_max']) && isset($_GET['y_max']) && isset($_GET['x_min']) && isset($_GET['y_min'])) {
$x_min = $_GET['x_min'];
$x_max = $_GET['x_max'];
$y_min = $_GET['y_min'];
$y_max = $_GET['y_max'];
$x = $x_min;
$y = $y_min;
if($x_min < 0) {
header("Location: map_viewer.php?x_min=".($x_min + 1)."&x_max=".($x_max + 1)."&y_min=".$y_min."&y_max=".$y_max);
} elseif($x_max > 20) {
header("Location: map_viewer.php?x_min=".($x_min - 1)."&x_max=".($x_max - 1)."&y_min=".$y_min."&y_max=".$y_max);
} else {
if($y_min < 0) {
header("Location: map_viewer.php?x_min=".$x_min."&x_max=".$x_max."&y_min=".($y_min + 1)."&y_max=".($y_max + 1));
} elseif($y_max > 10) {
header("Location: map_viewer.php?x_min=".($x_min - 1)."&x_max=".($x_max - 1)."&y_min=".$y_min."&y_max=".$y_max);
}
}
} else {
$x_min = 0;
$x_max = 6;
$y_min = 0;
$y_max = 6;
$x = 0;
$y = 0;
}
?>
include_once('dbconnect.php');
//Map size
if(isset($_GET['x_max']) && isset($_GET['y_max']) && isset($_GET['x_min']) && isset($_GET['y_min'])) {
$x_min = $_GET['x_min'];
$x_max = $_GET['x_max'];
$y_min = $_GET['y_min'];
$y_max = $_GET['y_max'];
$x = $x_min;
$y = $y_min;
if($x_min < 0) {
header("Location: map_viewer.php?x_min=".($x_min + 1)."&x_max=".($x_max + 1)."&y_min=".$y_min."&y_max=".$y_max);
} elseif($x_max > 20) {
header("Location: map_viewer.php?x_min=".($x_min - 1)."&x_max=".($x_max - 1)."&y_min=".$y_min."&y_max=".$y_max);
} else {
if($y_min < 0) {
header("Location: map_viewer.php?x_min=".$x_min."&x_max=".$x_max."&y_min=".($y_min + 1)."&y_max=".($y_max + 1));
} elseif($y_max > 10) {
header("Location: map_viewer.php?x_min=".($x_min - 1)."&x_max=".($x_max - 1)."&y_min=".$y_min."&y_max=".$y_max);
}
}
} else {
$x_min = 0;
$x_max = 6;
$y_min = 0;
$y_max = 6;
$x = 0;
$y = 0;
}
?>
<html>
<!-- Wereld kaart -->
<table border = 1>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
while($y <= $y_max) {
echo("<tr>");
while($x <= $x_max) {
$texture = mysqli_fetch_array(mysqli_query($worldmap,"SELECT * FROM map WHERE x = ".$x." AND y = ".$y." LIMIT 1"));
echo("<td>");
echo("<img src='images/texture_".$texture['texture'].".jpg' height = 40 width = 40 title = '(".$x.",".$y.")'/>");
echo("</td>");
$x++;
}
$x = $x_min;
echo("</tr>");
$y++;
}
$y = 0;
?>
while($y <= $y_max) {
echo("<tr>");
while($x <= $x_max) {
$texture = mysqli_fetch_array(mysqli_query($worldmap,"SELECT * FROM map WHERE x = ".$x." AND y = ".$y." LIMIT 1"));
echo("<td>");
echo("<img src='images/texture_".$texture['texture'].".jpg' height = 40 width = 40 title = '(".$x.",".$y.")'/>");
echo("</td>");
$x++;
}
$x = $x_min;
echo("</tr>");
$y++;
}
$y = 0;
?>
</table>
<!-- -->
<table border = 1>
<tr>
<td></td><td><center><a href = "map_viewer.php?x_min=&x_max=&y_min=&y_max=">+++</a></center></td><td></td>
</tr>
<tr>
<td><center><a href = "map_viewer.php?x_min=&x_max=&y_min=&y_max=">+++</a></center></td><td></td><td><center><a href = "map_viewer.php?x_min=&x_max=&y_min=&y_max=">+++</a></center></td>
</tr>
<tr>
<td></td><td><center><a href = "map_viewer.php?x_min=&x_max=&y_min=&y_max=">+++</a></center></td><td></td>
</tr>
</table>
</html>