Jump to content

Recommended Posts

hii can anyone could help me with this. i want to show my site statistics with image numbers like the one in "http://signup.wazzub.info"

I can do only this which shows only the numbers.

// Connect to the database

include "connect.php";

// Query the database and get the count

$result = mysql_query("SELECT * FROM tablename");

$num_rows = mysql_num_rows($result);

// Display the results

echo $num_rows;

 

Any help will be appreciated...

1. You should be using COUNT(*), as you do not need the full result set.

 

2. You need to link to your image files, or let PHP create the image for you.  The snippet below creates the image via PHP, you will need to do some tweaking.  It is commented up, so that shouldn't be a problem.

 

// Connect to the database

include "connect.php";

// Query the database and get the count

$result = mysql_query("SELECT COUNT(*) FROM tablename");

$rows = mysql_fetch_row($result);
$num_rows = $rows[0];

// Display the results

echo '<img src="image.php?gen=' . $num_rows . '" alt="' . $num_rows . '" />';

 

image.php

<?php
header('Content-type: image/png');
$text = $_GET['gen'];
$font = 'fonts/A.C.M.E._Explosive_Bold.ttf';  //location of your true type font.

// Create the image
$im = imagecreatetruecolor(800,600); //800x600

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 150, 150, 150);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 799, 599, $white);

// Add some shadow to the text
imagettftext($im, 20, 0, 31, 30, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 30, 29, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im); //create the image.
imagedestroy($im); //remove image from memory.
?>

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.