Jump to content

Image manipulation


zero_ZX

Recommended Posts

Hi,

I have this script, which is supposed to generate images, for each person in my database, and tell what their status are.

However, it can only print one person at a time, as it keeps having the same name i think.

 

I got no idea on what to search for, or how to do this so any help would be appriciated.

Here's my current code:

 


<?PHP



include("config.php");

$result = mysql_query("SELECT * FROM medarbejder ORDER BY medarbejder");

while($row = mysql_fetch_array($result))
IF ($row['status']==1)
{
	////////////////////////////////////////////////////////////////
	//					Start med indlæsning af billede          //
	//////////////////////////////////////////////////////////////

// Se side: http://discomoose.org/2005/10/19/write-text-on-to-an-existing-png-image-using-php/


// load the image from the file specified:

$im = imagecreatefrompng("blank.png");
// if there's an error, stop processing the page:

if(!$im)
{
die("Billedet kunne ikke findes.");
}

// define some colours to use with the image
$yellow = imagecolorallocate($im, 255, 255, 0);
$black = imagecolorallocate($im, 255, 255, 255);  //som vi laver hvid (i stedet for sort: 0, 0, 0

// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);

// draw a black rectangle across the bottom, say, 20 pixels of the image:
imagefilledrectangle($im, 0, ($height-80) , $width, $height, $black);

// now we want to write in the centre of the rectangle:
$font = 4; // store the int ID of the system font we're using in $font
$text = "" . $row['medarbejder'] . " (til stede)"; // store the text we're going to write in $text

// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2;

// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-60, $text, $yellow);

// output the image
// tell the browser what we're sending it
Header('Content-type: image/png');

// output the image as a png
imagepng($im);
$img = imagepng($im);

// tidy up
//imagedestroy($im);



echo "<TABLE border=0 bgcolor=#00FF00>";
echo "<tr>";
echo "<td width=700>" . $img . " (til stede)</td>";
echo "<br>";
echo "</tr>";

}
/*Else
{
echo "<TABLE border=0 bgcolor=#FF0000>";
echo "<tr>";
echo "<td width=700 align:left>" . $row['medarbejder'] . " (ikke til stede)</td>";	
echo "</tr>";
//echo "</table>";
//echo "<TABLE width=710 border=1 bgcolor=#FF0000>";
echo "<tr>";
echo "<td width=700>" . $row['kommentar'] . "</td>";
echo "<br>";
echo "</tr>";
//echo "</table>";
}
*/	
echo "</table>";
mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/203496-image-manipulation/
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.