Jump to content

[SOLVED] Always outputting same image... not desired


deadlyp99

Recommended Posts

What this code is designed to do, is to seperate my map, and use different images based on population.

Currently, it is outputting the same image every time "images/mapsquares/d00.gif".

 

Does a for loop only call the function one time and use the result every time, or is there an error in my code I cannot find? Also, will converting "GetCitySquareIcon" to a class rather then a function help at all? Because other parts of my code are not producing this error from what I've seen.

 

Thanks for any replies

 

<?php
		function GetCitySquareIcon($CityID, $OasisType, $CityPoP, $Relation)
		{
			$MapDIR = "images/mapsquares/";
			$Type = ".gif";
			$MapTypeImages = array('d00','d01','d02','d03','d04','d05','d10','d11','d12','d13','d14','d15','d20','d21','d22','d23','d24','d25','d30','d31','d32','d33','d35');
			$BlankMapImages = array('t0','t1','t2','t3','t4','t5','t6','t7','t8','t9');
			$OasisTypeImages = array('o1','o2','o3','o4','o5','o6','o7','o8','o9','o10','o11','o12','o99');

			if ($CityID >= 1)
			{
				if ($CityPop < 100)
				{
					return $MapDIR.$MapTypeImages[0].$Type;
				}
				elseif (($CityPoP > 100) && ($CityPoP < 250))
				{
					return $MapDIR.$MapTypeImages[6].$Type;
				}
				elseif (($CityPoP > 250) && ($CityPoP < 500))
				{
					return $MapDIR.$MapTypeImages[12].$Type;
				}
				elseif ($CityPoP > 500)
				{
					return $MapDIR.$MapTypeImages[18].$Type;
				}
			}
}


			for ($Y = $StartY; $Y >= $EndY; $Y--)
			{	
				echo "<div id=\"row".$Y."\">";
				array_push($Yarray, $Y);
				for ($X = $StartX; $X <= $EndX; $X++)
				{
					echo "<div class=\"". $CssClass.$CssClassNum."\" alt=\"".$X.",".$Y."\"  style=\"z-index:5;width:74px;height:74px;background:url('".GetCitySquareIcon($CID, $OType, $Pop, 0)."');\"></div>\n";
					array_push($Xarray, $X);
					$CssClassNum++;	
				}
				echo "</div><br />";
			}
?>

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.