subhomoy Posted May 25, 2012 Share Posted May 25, 2012 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... Quote Link to comment https://forums.phpfreaks.com/topic/263138-count-the-no-of-rows-using-image-numbers/ Share on other sites More sharing options...
Barand Posted May 25, 2012 Share Posted May 25, 2012 If you only want the count it's more efficient to $result = mysql_query("SELECT COUNT(*) FROM tablename"); $numRows = mysql_result($result, 0, 0); Quote Link to comment https://forums.phpfreaks.com/topic/263138-count-the-no-of-rows-using-image-numbers/#findComment-1348644 Share on other sites More sharing options...
jcbones Posted May 25, 2012 Share Posted May 25, 2012 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. ?> Quote Link to comment https://forums.phpfreaks.com/topic/263138-count-the-no-of-rows-using-image-numbers/#findComment-1348645 Share on other sites More sharing options...
subhomoy Posted May 25, 2012 Author Share Posted May 25, 2012 @jcbones Thanks for the help. You are toooooooooooooooo gooooooooodddd. Thanks once again... Quote Link to comment https://forums.phpfreaks.com/topic/263138-count-the-no-of-rows-using-image-numbers/#findComment-1348676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.