View Single Post
Old 28.03.2006, 04:09   #9
ANRDaemon
Архивный участник
 
Join Date: Feb 2006
Posts: 158
Default

Code:
<?php

require_once(DB interface);
require_once(Some configs);

$DB = new database connection;

// configure map dimension here
$worldMap = array(
  'startX' => 16,
  'startY' => 10,
  'lastX' => 26,
  'lastY' => 26,
);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>World map</title>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body><table class="worldMap">
<?php

for($y = $worldMap['startY']; $y <= $worldMap['lastY']; $y++)
{
  print("<tr>\n");
  for($x = $worldMap['startX']; $x <= $worldMap['lastX']; $x++)
  {
    if(file_exists(sprintf('img/%02d_%02d.png', $x, $y)))
    {
      $content = "X: {$x} Y: {$y}
\n";
      // Fetch and paste some data from DB to map
      printf('  <td><div class="mapTile" style="background-image: url(\'img/%02d_%02d.png\');"><div>%s</div></div></td>
', $x, $y, $content);
    }
    else
    {
      print('<td></td>');
    }
  }
  print("</tr>\n");
}

?>
</table>
</body>
</html>
Place XX_YY.png files in ./img subfolder and see something like this:
http://www.l2aw.ru/shadows/HDGE/map/
ANRDaemon is offline