$row['locX'], 'locY' => $row['locY']); } mysql_close(); //Width and height of each region $regionSize = 80; //Center on a coordinate $centerX = 997; $centerY = 1003; //set X, Y upper bounds $maxX = 1003; $maxY = 1003; //set X, Y lower bounds $minX = 996; $minY = 996; //Create an image, properly sized $imageWidth = (($maxX-$minX)*$regionSize); $imageHeight = (($maxY-$minY)*$regionSize); $heading = ' '; //foreach region, plot square at position in image multiplied by region width foreach($regions as $regionName => $coords) { if($coords['locX'] > $minX AND $coords['locX'] < $maxX) { if($coords['locY'] > $minY AND $coords['locY'] < $maxY) { $rectangles .= ''; $text .= ''.$regionName.'X='.$coords['locX'].'Y='.$coords['locY'].''; } } } $ending = ''; $stringData = $heading.$rectangles.$text.$ending; // Specify configuration $config = array( 'indent' => true, 'input-xml' => true, 'output-xml' => true, 'wrap' => 0); // Tidy $tidy = new tidy; $tidy->parseString($stringData, $config, "utf8"); $tidy->cleanRepair(); $stringData = (string)$tidy; $fh = fopen('map.svg', 'w'); fwrite($fh, $stringData); fclose($fh); exec('convert map.svg map.png'); echo '


' ?>