Jump to content

Creating Dynamic Images


u214

Recommended Posts

Hello guys. I'm kinda new to PHP, I've been understanding everything so far. I have trouble with "imagestring"

 

What I want is to query a row in MySQL. I want to display some of that info in the image. It's not working properly.

 

Here's the code:

<?php
$imagepath="css/images/dog.jpg";

$image=imagecreatefromjpeg($imagepath);

$imgheight=imagesy($image);

$color=imagecolorallocate($image, 255, 255, 255);

include("config.php");
$result = mysql_query("SELECT * FROM playerinfo WHERE Level > 0 ORDER BY Level DESC", $connect);

while($myrow = mysql_fetch_row($result))
{
	// Not working properly.
	imagestring($image, 5, 50, $imgheight-50, $myrow[0], $color);
}

// This line works like it should:
//imagestring($image, 5, 50, $imgheight-50, "Using it like this works!", $color);

header('Content-Type: image/jpeg');

imagejpeg($image);

?>

 

Any help will be GREATLY appreciated it. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/235207-creating-dynamic-images/
Share on other sites

I found the problem. It was a silly mistake.

 

When requiring the string, it was to display ALL the info that it found with "Level" greater than 0. So everything was just displaying on top of each other, making the text un-readable.

 

I changed it to: SELECT * FROM playerinfo WHERE user = 'test'

 

And it gave just what I wanted.

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.