$row['locX'], 'locY' => $row['locY']); } mysql_close(); //Width and height of each region $regionSize = 75; //Center on a coordinate $centerX = 9994; $centerY = 10007; //set X, Y upper bounds $maxX = 10010; $maxY = 10007; //set X, Y lower bounds $minX = 9994; $minY = 9993; //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.''; } } } $ending = ''; $stringData = $heading.$rectangles.$text.$ending; $fh = fopen('map2.svg', 'w'); fwrite($fh, $stringData); fclose($fh); echo '
' ?>