NArc0t1c Posted October 2, 2007 Share Posted October 2, 2007 I'm currently busy with a project that involves the usage of a graph. I store timestamp in a database, and then work out the average of it, and then with a loop, show the correct amount. It's currently show all as zero, which is incorrect. Here is my script. <?php // create image $image = imagecreate(480,120); // allocate some solors $white = imagecolorallocate($image, 0xFB, 0xFB, 0xFB); $black = imagecolorallocate($image, 0x00, 0x00, 0x00); $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90); $navy = imagecolorallocate($image, 0x00, 0x66, 0xCC); $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50); $red = imagecolorallocate($image, 0xFF, 0x00, 0x00); $darkred = imagecolorallocate($image, 0x90, 0x00, 0x00); $whites = imagecolorallocate($image, 0x20, 0x28, 0x3E); imagefill($image,0,0,$white); imageline($image,5,105,475,105,$black); $s = 0; $list = 0; $c = 0; $ps = 1; $chars = array(' 1', ' 2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'); for($i=20;$i<=720;$i+=20){ imageline($image,$i,105,$i,115,$black); imagestring($image, 2, $i-15,105,$chars[$c],$black); $c++; $ps++;} function add($s,$num){ global $image, $whites; $num = (100-$num); for($a=$s;$a<$s+10;$a++) imageline($image, $a,104,$a,$num,$whites); } $mc = mysql_connect('127.0.0.1:3306','root',''); mysql_query('USE db'); $id = $_SESSION['login']; $x = 0; for($i=1;$i<=24;$i++) { $qy = mysql_query("SELECT AVG(hour) FROM activity WHERE empid='$id' AND hour='$i'"); add($x+5, mysql_result($qy,0)); $x += 20; } header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> Thanks in advance. Ferdi Link to comment https://forums.phpfreaks.com/topic/71549-stats-image/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.