|
 |
|
รบกวนด้วย ครับ สมมุติ 10,20,30,40,50,60,70,80,90 จะขึ้นตรงตาม ตัวนี้ "ASD","CSD","HRG","LBG","LSD","OBD","PFR","RAL","WSG" แต่.. |
|
 |
|
|
 |
 |
|
รบกวนด้วย ครับ สมมุติ (10,20,30,40,50,60,70,80,90) จะขึ้นตรงตาม ตัวนี้ "ASD","CSD","HRG","LBG","LSD","OBD","PFR","RAL","WSG" แต่ ถ้า 50 ไม่มี หรือเป็น 0 (10,20,30,40,_,60,70,80,90) มันจะเอาข้อมูลไปต่อ ท้าย 90 ทำให้ ข้อมูลไม่ตรง เช่น 90 ต้องเป็น WSG แต่กลายเป็น 0 แทน รบกวน พี่ ๆ ด้วย ครับ งง..


Code (PHP)
$strSql="select order_generation , order_size 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","CSD","HRG","LBG","LSD","OBD","PFR","RAL","WSG"); // 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
}
}
}
$sarray[] = sort($hdata);
$data=array(10,20,30, __,50,__,70,90,);
Tag : PHP, MySQL, HTML/CSS

|
ประวัติการแก้ไข 2013-03-26 11:54:56
|
 |
 |
 |
 |
Date :
2013-03-26 11:52:50 |
By :
TonsoR |
View :
820 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$sarray[] = sort($hdata);
$data=array(10,20,30, 0 ,50, 0 ,70,90,);
ใส่ 0 แทน __ ไม่ได้เหรอค่ะ
|
 |
 |
 |
 |
Date :
2013-03-26 12:21:55 |
By :
survivor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผลลัพธ์
60.8192984845= ASD
5.94201782232= CSD
219.118831146= HRG
52.5086122611= LSD
4.28685495677= PFR
20.0435891616= RAL
105.582289863= WSG
0 = LBG
0 = OBD
แต่ที่ผมอยากให้เรียงคือ ไม่ทราบ พอจะเทียบยังงัย ครับ
60.8192984845= ASD
5.94201782232= CSD
219.118831146= HRG
0 = LBG
52.5086122611= LSD
0 = OBD
4.28685495677= PFR
20.0435891616= RAL
105.582289863= WSG
ให้เรียงตามตัวนี้ ครับ
Code (PHP)
$model = array("ASD","CSD","HRG","LBG","LSD","OBD","PFR","RAL","WSG"); // Model
Code (PHP)
$strSql="select order_generation , order_size 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","CSD","HRG","LBG","LSD","OBD","PFR","RAL","WSG"); // 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
}
}
}
$sarray[] = sort($hdata);
//$data=array(10,20,30, __,50,__,70,90,);
$data[]=($sum_selec[0] * $size_2[0])."<br>";
$data[]=($sum_selec[1] * $size_2[1])."<br>";
$data[]=($sum_selec[2] * $size_2[2])."<br>";
$data[]=($sum_selec[3] * $size_2[3])."<br>";
$data[]=($sum_selec[4] * $size_2[4])."<br>";
$data[]=($sum_selec[5] * $size_2[5])."<br>";
$data[]=($sum_selec[6] * $size_2[6])."<br>";
$data[]=($sum_selec[7] * $size_2[7])."<br>";
$data[]=($sum_selec[8] * $size_2[8])."<br>";
เหมือนโค๊ดตัวนี้ ไม่ ได้เทียบค่า เลย ไม่ รู้ว่า ตรงกับโมเดว ไหน หรือเปล่า ครับ
Code (PHP)
$data[]=($sum_selec[0] * $size_2[0])."<br>";
$data[]=($sum_selec[1] * $size_2[1])."<br>";
$data[]=($sum_selec[2] * $size_2[2])."<br>";
$data[]=($sum_selec[3] * $size_2[3])."<br>";
$data[]=($sum_selec[4] * $size_2[4])."<br>";
$data[]=($sum_selec[5] * $size_2[5])."<br>";
$data[]=($sum_selec[6] * $size_2[6])."<br>";
$data[]=($sum_selec[7] * $size_2[7])."<br>";
$data[]=($sum_selec[8] * $size_2[8])."<br>";
|
ประวัติการแก้ไข 2013-03-26 14:25:36 2013-03-26 14:26:19 2013-03-26 14:27:15 2013-03-26 14:30:30 2013-03-26 14:31:57 2013-03-26 14:47:11
 |
 |
 |
 |
Date :
2013-03-26 14:23:20 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|