I am trying to make a script which allows a visitor to click on a map and mark their location. It submits the coordinates to a mysql database. Then when the php script 'draw.php' parses the data, it is supposed to open a preexisting jpeg or gif map file, and draw an orange dot using imagesetpixel for each coordinate in the database.
The code for draw.php is as follows;
<?
$db=mysql_connect('localhost', 'markar2', 'mongoose');
mysql_select_db("markar_nu_-_main",$db);
$imagef="map.jpg";
$im = imagecreatefromjpeg($imagef);
$result=mysql_query("SELECT `x`,`y` FROM `map`");
$tot=mysql_num_rows($result);
$i=0;
$dot=imagecolorallocate($im, 255, 156, 0);
while ($i < $tot) {
$x=mysql_result($result,$i,"x");
$y=mysql_result($result,$i,"y");
imagesetpixel($im, $x, $y, $dot);
$i++;
}
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>
At the moment, all the dots it draws are a mid range grey, very hard to see.
Thanks in advance