Jump to content

centre align?


pouncer

Recommended Posts

<? 
/* We need this in order to return a picture */ 
header ("Content-type: image/png"); 

$graph_data = array( 
   "question" => "Rating for this item" , 
   "1" => 82 , 
   "2" => 18,
   "3" => 0,
   "4" => 0,
   "5" => 0
	); 

$im = ImageCreate(400, 160);

$background_color = imagecolorallocate($im, 200, 200, 200); 
$text_color = imagecolorallocate($im, 233, 14, 91); 
$bar_color = imagecolorallocate($im, 0, 0, 0); 
$bar_color_fill = imagecolorallocate($im, 150, 150, 255); 

imagefill($im, 0, 0, $background_color); 

ImageString ($im, 5, 95, 5,  $graph_data["question"], $text_color); 

for ($i = 1; $i <= 5; $i++) {
	$space = $i * 80 - 50;
	$text = $i . ": " . $graph_data[$i] . "%";

	ImageString ($im, 2, $space, 130,  $text, $text_color); 
}

for ($i = 1; $i <= 5; $i++) {
	$x1 = $i * 80 - 50;
	$bar_height = 120 - $graph_data[$i];
	$bar_width = $x1 + 20;

	imagerectangle($im, $x1, $bar_height, $bar_width, 120 ,$bar_color);
	imagefill($im, $x1, 120, $bar_color_fill); 
}

echo imagepng($im); 
?>  

 

it shows the image in the top left corner.

 

how do i get it to show in the centre of the page?

Link to comment
https://forums.phpfreaks.com/topic/46357-centre-align/
Share on other sites

yeah i saw that... i had to upload it to a server first... my local php setup aint supporting the imagecreate() i think... need to figure out what to enable to make that work =) i'm just trying to look through it to see if i can figure something out... but as i said when i added my last post... been awake for more than 30 hours now and also i've never worked with imagecreate()

Link to comment
https://forums.phpfreaks.com/topic/46357-centre-align/#findComment-225510
Share on other sites

not at the moment... currently going through every image function on php.net

 

you might wanna read this: http://no.php.net/manual/en/function.getimagesize.php (go trough all the codes on left side)

 

unless an more experienced person can help you out...

Link to comment
https://forums.phpfreaks.com/topic/46357-centre-align/#findComment-225514
Share on other sites

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.