I have a series of three scripts, and the goal of them is to make an interactive image, where one can click on part of the image, and have that part of the image change colors. Right now, it works for the first 9 rows, but when it gets into double digits for the y coordinate, it stops working. If you want to see the script in action, go here http://design.markar.nu/colors.php
<?
if ($coords_x && $coords_y) {
$xx=round(($coords_x+10)/20);
$xx2=round(($coords_x+5)/10);
$xx_even=($xx2/2)-round($xx2/2);
if ($xx_even == 0) {
$yy=round(($coords_y)/11)*2-1;
} else {
$yy=(round(($coords_y-5)/11))*2;
}
$cell=$xx.",".$yy;
$cell2=($xx+1).",".$yy;
$exec1=mysql_query("UPDATE game SET r=200, g=100, flag=1 WHERE cell='".$cell."'");
$exec2=mysql_query("UPDATE game SET flag=1 WHERE cell='".$cell2."'");
echo $cell;
echo "<br>";
echo $cell2;
echo "<br>";
echo $xx2;
?>
<form action="" method="post">
<input type="image" src="map.php" name="coords" value="coords">
</form>
The contents of the map image script is as follows;
$xarr=array();
$yarr=array();
$flags=mysql_query("SELECT `cell` FROM `game` WHERE `flag`='1'");
$tot_flag=mysql_num_rows($flags);
$flag_num="0";
while ($flag_num < $tot_flag) {
$gen_coords=mysql_result($flags,$flag_num,"cell");
list($x_new, $y_new)=split(",",$gen_coords);
array_push($xarr, $x_new);
array_push($yarr, $y_new);
$flag_num++;
}
$y=1;
while ($y < 63) {
$y6=$y*6;
$x=1;
$y_even=($y/2)-round($y/2);
while ($x < 35) {
$x20=$x*20;
if ((in_array($x, $xarr))&&(in_array($y, $yarr))) {
$colors=mysql_query("SELECT `r`,`g`,`b` FROM `game` WHERE `cell`='".$x.",".$y."'");
$r=mysql_result($colors,0,"r");
$g=mysql_result($colors,0,"g");
$b=mysql_result($colors,0,"b");
}
$ccolor = imagecolorallocate($im, $r, $g, $b);
imagefilledpolygon($im, $values, 6, $ccolor );
$x++;
}
$y++;
}
sorry for the long post...
thanks in advance for your help