 |
|
|
 |
 |
|
ใช้ php เรียกข้อมูลมาเวลาใส่ค่าให้กับกราฟก็ใส่เป็นตัวแปร array หรือ กำหนดค่าตัวแปรใหม่ก่อนก็ได้
แล้วค่อยใส่ค่าเข้าไป
|
 |
 |
 |
 |
Date :
30 ม.ค. 2550 23:06:30 |
By :
ลองตามแนวคิดนะครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาโค้ด มาดุซิ ครับ
จะลองแก้ดู
|
 |
 |
 |
 |
Date :
31 ม.ค. 2550 03:08:07 |
By :
arsachi |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยดูให้หน่อยนะค่ะ ทำไม่ไม่วนอันเดียวอ่ะ
<?php # barshade.php
include "connectionDb.php";
$sql="select orderid,pro_id,item_price,sum(quantity) quantity
from order_item group by pro_id order by quantity desc";
$result=mysql_db_query($dbname,$sql);
$im = imagecreate(800,105);
$back = ImageColorAllocate($im,240,255,50);
$blk = ImageColorAllocate($im,0,0,200);
while ($rs=mysql_fetch_array($result)){
$orderid=$rs[orderid];
$pro_id=$rs[pro_id];
$item_price=$rs[item_price];
$quantity=$rs[quantity];
$sql2="select pd_name from tbl_product where
pd_id='$pro_id'";
$result2=mysql_db_query($dbname,$sql2);
$rs2=mysql_fetch_array($result2);
$pd_name=$rs2[pd_name];
drawbar($im,45,5,$quantity,$pro_id);
$shadow = ImageColorAllocate($im,170,170,170);
imagestring($im, 5, 61, 86, "My Bar Chart!", $shadow);
imagestring($im, 5, 60, 85, "My Bar Chart!", $blk);
}
Header("Content-type: image/png");
imagePNG($im);
imagedestroy($im);
$i=0;
function drawbar($im,$x1,$y1,$rating,$txt) {
for($i;$quantity<0;$i++);
{
$barlen=$rating * 4; // scale
$red = ImageColorAllocate($im,200,0,0);
$y=0 ;
for ($i = 50; $i <= 250; $i+=50) {
$fill = ImageColorAllocate($im,0,$i,0);
ImageFilledRectangle($im,$x1,$y1+$y, $x1+$barlen, $y1+$y,$fill);
$y=$y+1;
}
for ($i = 250; $i >= 50; $i-=30) {
$fill = ImageColorAllocate($im,0,$i,0);
ImageFilledRectangle($im,$x1,$y1+$y, $x1+$barlen, $y1+$y,$fill);
$y=$y+1;
}
imagestring($im, 3, 4, $y1-1, $txt , $red);
imagestring($im, 2, $barlen+49, $y1-1, $rating. '%' , $red);
}
}
?>
|
 |
 |
 |
 |
Date :
31 ม.ค. 2550 16:38:21 |
By :
ฟน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|