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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.