|
 |
|
แนะนำด้วย ครับ ผมอยาก (บวก) เลขจาก ฐานข้อมูล เช่น HRG = 100 สมมุติ มี HRG 4ตัว ก็ เอาค่าของ HRG 4ตัวบวกกัน |
|
 |
|
|
 |
 |
|

Code (PHP)
<?
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>";
// เ่ช่น 44" X 20" = 5677.408
}
?>
<?php
$sqlq="select idcode_pb,order_ID, order_generation ,order_size from `order` order by order_ID DESC ";
$que=mysql_query($sqlq);
while($aam=mysql_fetch_array($que)){
$idcode_pb=$aam['idcode_pb'];
$order_ID=$aam['order_ID'];
$order_size=$aam['order_size'];
$order_generation=$aam['order_generation'];
//}
// code แยกตัว อักษร ทีละตัว อักษร -------------------------
# คือ ตัด - แล้ว แทนด้วย เครื่องหมาย #
$A = "$order_generation";
$A = str_replace("-" ,"#",str_replace(")","#",str_replace("(","#",$A)));
$B = explode("#",$A);# แยก string แล้ว เก็บ เป็น array
print_r($B)."<br>";
//ผลลัพธ์ เช่น Array ( [0] => 1 [1] => RAL )
square
// เทียบ string แยก ตัวอักษร---------------------------------
$array1 = array("a" =>"$B[0]","$B[1]","$B[2]","$B[3]","$B[4]","$B[5]","$B[6]","$B[7]","$B[8]","$B[9]","$B[10]","$B[11]","$B[12]");
$array2 = array("b" =>"ASD","ARD","CSD","CRD","RD","HRG","WSG","LBG","LSD","RAL","OBD","PFR","FAG","SAL","WD");
$result = array_intersect($array1, $array2);
print_r($result[0])."<br>";
// ผลลัพธ์ RAL
//-------------------------------------------------------
$quiz = array("$order_size"); // เช่น 44" X 20" -----------
foreach($quiz as $each){
//str2exp2($each)."<br>";
}
// แยกข้อความ โดยใช้ ช่องว่าง....
$piz = "$order_size";
$pieces = explode(" ", $piz);
//print_r($pieces[1]);
//-------------------------------------
if($B[0]=="WD" or $B[1]=="WD" or $B[2]=="WD" or $B[3]=="WD" or $B[4]=="WD"){
//echo $mann=str2exp_1($each)+str2exp_1($each); ถ้านำค่า 2 ค่ามาบวกัน ทำแบบนี้
for ($i=1; $i<=2;$i++){ // ภ้า ค้นเจอ คำว่า WD ให้ วนลูปโชว์ 2 ค่า
echo str2exp2($each)." "."square"."<br>";
}
}else if($B[0]==1 and $B[1]=="LSD" and $pieces[1]!="X"){
$LSD1=3.81;
$sumn_1= ($LSD1 * $each);
echo $sumn_1.' '."square"."<br>";
}else if($B[0]==2 and $B[1]="LSD" and $pieces[1]!="X"){
$LSD2=7.62;
$sumn_2 = ($LSD2 * $each);
echo $sumn_2.' '."square"."<br>";
}else if($B[0]==3 and $B[1]="LSD" and $pieces[1]!="X"){
$LSD3=11.43;
$sumn_3 = ($LSD3 * $each);
echo $sumn_3.' '."square"."<br>";
}else if($B[0]==4 and $B[1]="LSD" and $pieces[1]!="X"){
$LSD4=15.24;
$sumn_4 = ($LSD4 * $each);
echo $sumn_4.' '."square"."<br>";
}else if($B[0]==5 and $B[1]="LSD" and $pieces[1]!="X"){
$LSD5=19.05;
$sumn_5 =($LSD5 * $each);
echo $sumn_5.' '."square"."<br>";
}else{
echo str2exp2($each).' '."square"."<HR>";
}
?>
<?
}
?>
ภาพ ..

Tag : PHP, Ms Access, HTML/CSS, Ajax, jQuery, iPod

|
ประวัติการแก้ไข 2012-12-28 10:11:57 2012-12-28 10:24:34 2012-12-28 10:31:41 2012-12-28 10:34:02 2012-12-28 11:02:38
|
 |
 |
 |
 |
Date :
2012-12-28 09:56:01 |
By :
TonsoR |
View :
1062 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ติดที่ว่า ค่าของผมใน table เช่น 4-CSD-F(WD)
table ครับ ที่ เห็น เป็นโมเดว ผม จับมา แยกสริง แล้ว เอาเฉพาะ ตัวโมเดว เช่น CSD

|
ประวัติการแก้ไข 2012-12-28 14:20:42
 |
 |
 |
 |
Date :
2012-12-28 14:13:36 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|