|
 |
|
รบกวน ด้วย ครับ ผมอยากหาผลรวมขอฟิว ครับ โดยแยกตามกลุ่ม ของ ฟิว ครับ |
|
 |
|
|
 |
 |
|
ผมอยากหาผลรวมของฟิว โดย ให้ order_genneration เดียวกันให้เอา ค่า order_size มาบวกกัน ครับ ตอนนี้ผมหาผลลับของ order_size แล้ว ครับ

อันนี้
Code (PHP)
<?php
// คือ หาค่า ของ ผล คูณ ของ order_size-------------------------------------------
function str2exp2($string){
//echo $string;
$str_exp = str_replace("\"","X2.54",$string);
$str_exp = str_replace("cm","",$str_exp);
$str_exp = str_replace(" ","+",$str_exp);
$expression = explode("X",$str_exp);
$expression = array_filter($expression);
//print_r($expression);
$result=1;
foreach($expression as $val){
if(strstr($val,"/") && strstr($val,"+")){
list($a,$b) = explode("+",$val);
list($c,$d) = explode("/",$b);
$result *= ($a+($c/$d));
}else{
$result *= $val;
}
}
echo " - ".$result."<br>";// ผลคูณ ของ order_size เช่น 14" X 14"
}
?>
อันนี้โค๊ดกราฟ คับ
Code (PHP)
$strSql="select order_generation from `order` ";
$query = mysql_query($strSql);
$num = mysql_num_rows($query);
$resultArray = array();
for ($i = 0;$i<$num;$i++) {
$result = mysql_fetch_array($query);
array_push($resultArray,$result['order_generation']);
}
$hdata = array();
$model = array("ASD","ARD","CSD","CRD","RD","HRG","WSG","LBG","LSD","RAL","OBD","PFR","FAG","SAL"); // Model
for($i=0;$i<=count($resultArray);$i++){ // วนรอบตามจำนวนของ ตัวอย่าง
$Split = explode("-",$resultArray[$i]); // แยกโดย -
foreach($Split as $Val){ // วนรอบตามจำนวนที่แยกได้
if(in_array($Val,$model) and !in_array($Val,$hdata)){ // เปรียบเทียบว่า อยู่ใน $model หรือไม่ และต้องไม่อยู่ใน $hdata ค่าที่ได้จึงจะไม่ซ้ำกัน
array_push($hdata,$Val); //นำค่าที่ได้ไปใส่ $hdata
}
}
}// wheile จากฐานข้อมูล
//echo "<pre>";
//print_r($hdata);
//echo "</pre>";
$data=array(5100,10100,6100,8100,5100,2100,8100,9100,6100,2100,9100,1100,2100,7100); // อันนี้ความสูงของกราฟ คับ ผมอยากเอาค่าที่หาได้ จาก โค๊ด ข้างบน order_size มาใส่ตรงนี้ครับ

ผมอยากเอา ผลบวกของ order_size มาใส่เป็นความสูงของกราฟ ครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript, Windows

|
ประวัติการแก้ไข 2013-01-09 13:59:49 2013-01-09 14:07:14 2013-01-09 14:14:02 2013-01-09 14:19:57
|
 |
 |
 |
 |
Date :
2013-01-09 13:46:05 |
By :
TonsoR |
View :
991 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะทำที่ Query ได้น่ะครับ ด้วยการ SUM แล้ว GROUP BY ครับ
|
 |
 |
 |
 |
Date :
2013-01-10 10:17:19 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ข้อมูลที่ จะ sum มัน sum ไม่ได้ ครับ เพราะ ฟิวด์ เก็บ ค่าเป็น 14" X 14" แต่ผมหาค่าได้แล้ว 71.12 cm แต่ไม่ได้เก็บในฐานข้อมูล ต้องสร้าง ฟิวด์ เพิ่มหรือเปล่า ครับ
ส่วนข้อมูล ของ order_genneration เช่น รุ่น HRG มีหลายค่า ไม่สามารถ Group by ได้ ครับ ยกตัวอย่างเช่น
1-HRG-A ,1-HRG-V, 1-HRG-Q , 1-HRG-W
หรือ อีก รุ่น ของ ASD เช่น 2-ASD-F , 1-ASD-O , 2-ASD-B
|
ประวัติการแก้ไข 2013-01-11 09:29:50
 |
 |
 |
 |
Date :
2013-01-11 09:25:44 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลอง GROUP BY แล้ว ครับ ไม่ได้
ช่วยผม ที ครับ ผม ทำมา หลายวันแล้ว ครับ T T
|
ประวัติการแก้ไข 2013-01-12 08:21:05
 |
 |
 |
 |
Date :
2013-01-11 16:58:12 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|