Jump to content

count the no of rows using image numbers..


subhomoy

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

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.