Generate Rank Graphic/Image From PHP

Downloads:1196 Bookmark this code Bookmark and Share
Rank : Not rated yet
Rated by : 0 user(s)
Developer:Colin Smith  |   4 submission(s)
Date Uploaded:May 16,2008
Level:Begginer
Size: 0 Bytes
Category:PHP -> Images/Graphics
Developer Says:

The sample code is a php script that receives a number between 0 & 10 and generates a graphic that shows the rank. Using a single line of code you can include graphic ranks in your web sites. To view online Demo Click Here

<?
	header("Content-type: Image/png");
	$img_width=102;
	$img_height=10;	
	$img=imagecreatetruecolor($img_width,$img_height);
 
	$maroon=imagecolorallocate($img,153,0,0);
	$grey=imagecolorallocate($img,220,220,220);	
	$dark_grey=imagecolorallocate($img,190,190,190);
 
	imagefilledrectangle($img,0,0,$img_width-1,$img_height-1,$grey);
	imagerectangle($img,0,0,$img_width-1,$img_height-1,$dark_grey);
 
	$rank=intval($_REQUEST['rank']);
	if($rank<0 || $rank>10){
		imagepng($img);
		die();
	};	
 
	$left=2;
	$gap=3;
	$box_width=7;
	for($i=0;$i<$rank;$i++){
		imagefilledrectangle($img,$left,2,$left+$box_width,$img_height-3,$maroon);
		$left+=$box_width+$gap;
	}
	imagepng($img);
 ?>

The above code was highlighted with Neat Highlighter


User Reviews
There are no user reviews on this code
Leave a Comment
Age (Required, will not be shown)
Name
Email (Required, will not be shown)
Website (Optional, starting with http://)
 
Rate this code
Poor   1 2 3 4 5   Outstanding
Are you human ?

Enter the code shown above