Jump to content

Recommended Posts

How would I create a dynamic image that would get $Num and put that in the image along with something that would be constant like "there are ".$Num. " users in the database"; in the image?

 

<?php
$Num = mysql_query("SELECT * FROM `users`");
$Num = mysql_num_rows($Num);

echo "<center>There are <b><u>" . $Num . "</b></u> Users in the database.<br /></center>";
?>

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

 

I tired:

 

<?php

include('header.php');

$Num = mysql_query("SELECT * FROM `users`");
$Num = mysql_num_rows($Num);

// Create a 200*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, 'There are '.$Num.' Users in the EOdata User Database', $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

 

And it didn't work. Also where would I go to view this image?

Link to comment
https://forums.phpfreaks.com/topic/124227-php-dynamic-images/#findComment-641504
Share on other sites

what happens in header.php? Basically you're setting the PHP file to display as an image, so you'd just use something like:

 

<img src="your-php-file.php" />

 

You can't print out any HTML in the page though otherwise it won't work!

 

Adam

Link to comment
https://forums.phpfreaks.com/topic/124227-php-dynamic-images/#findComment-641517
Share on other sites

what happens in header.php? Basically you're setting the PHP file to display as an image, so you'd just use something like:

 

<img src="your-php-file.php" />

 

You can't print out any HTML in the page though otherwise it won't work!

 

Adam

 

header.php is connect information for MySql. Help plz x.x

Link to comment
https://forums.phpfreaks.com/topic/124227-php-dynamic-images/#findComment-641540
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.