Jump to content

Help with GD. and a random thing.


Dvalin

Recommended Posts

Hay all, I'v been looking for a place to post to ask for some help and then found this forum, I apologise if this is in the wrong section.

 

I have some code bellow, that loads my map background image, and then cycles through my database picking out any icons that then go on the map, these icons are then merged with the map, and then the final image is output.

 

<?php
$map=imagecreatefrompng('maps/'.$lmap.'.png');
while($row=mysql_fetch_row($result)){

$geticon 		= 	mysql_query("SELECT * FROM map_icons WHERE id='".$row[1]."' ", $link);
$geticon_row	=	mysql_fetch_row($geticon);

$src = imagecreatefrompng('icons/'.$geticon_row[3]);
//imagecopymerge($map, $src, $row[3], $row[4], 0, 0, 15, 15, 100);
imagecopy($map, $src, $row[3]-7, $row[4]-7, 0, 0, 15, 15);
imagedestroy($src);
}

// Output and free from memory
header('Content-Type: image/png');
imagepng($map);

imagedestroy($map);
imagedestroy($src);
?>

 

This works fine, I then pull the above code into my main site like this.

 

<img onclick="show_reticle();" src="map.php?map=<?php echo $lmap.$gfilt; ?>" alt="Image Map Display" name="mainmap" width="800" height="600" border="0" usemap="#map.map" id="mainmap" />

 

The problem I have is that my browser seems to be caching the images, which normally isnt an issue but I actually need to force a reload each time because the user might have placed a new marker, and the image would then be different.

 

I normally need to force refresh or spam the refresh button a few times to get it to load the new image which is really annoying.

 

My other little issue is that I load the map I want by calling its number like Map=1 would be map 1. map 1.2 would be the second map bellow 1, and so on and so on.. there are 8 maps per middle map, and 10 middle maps, so their numbers like this 1.png level 1, 1.1.png level 2 and 1.1.1.png.

 

The issue here is when I try to load map 1.10.png it loads 1.1.png so it seems to be ignoring the "0" so when I do map=1.10 I get map 1.1 not 1.10

 

Anyway . hope you can help. been scratching my head over this one for a wee bit now. im not the best php coder, just learning so . well anyway thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/164005-help-with-gd-and-a-random-thing/
Share on other sites

Well, for every call you could try this:

 

<img onclick="show_reticle();" src="map.php?map=<?php echo $lmap.$gfilt; ?>&<?php echo date("YmdHis"); ?>" alt="Image Map Display" name="mainmap" width="800" height="600" border="0" usemap="#map.map" id="mainmap" />

 

That way, the image that is called is always different, as the parameters have changed. I think this works.

Thanks I found out that it was a function I was calling with a switch in it, I basiclly wrote a switch to compare values and then set the right thing, but the switch we looking at it like it was a float and dropping the last 0.

 

I find it by using regular expression. thanks for the tip tho. I wouldnt have thought of that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.