我找不到循环这种数组结构的方法。任何人都遇到过它。
Print_r输出
Array (
[0] => Array ( [0] => [LABOR_NO] => [1] => 3 [WORK_CODE] => 3 [2] => [MHR] => [3] => [PHR] => [4] => [PESO_VALUE] => )
[1] => Array ( [0] => [LABOR_NO] => [1] => 3 [WORK_CODE] => 3 [2] => [MHR] => [3] => [PHR] => [4] => [PESO_VALUE] => )
[2] => Array ( [0] => 1 [LABOR_NO] => 1 [1] => 3 [WORK_CODE] => 3 [2] => 2.50 [MHR] => 2.50 [3] => 0.00 [PHR] => 0.00 [4] => 3000.00 [PESO_VALUE] => 3000.00 )
)
Vardump输出
array(3) {
[0]=> array(10) {
[0]=> NULL ["LABOR_NO"]=> NULL [1]=> string(1) "3" ["WORK_CODE"]=> string(1) "3" [2]=> NULL ["MHR"]=> NULL [3]=> NULL ["PHR"]=> NULL [4]=> NULL ["PESO_VALUE"]=> NULL }
[1]=> array(10) { [0]=> NULL ["LABOR_NO"]=> NULL [1]=> string(1) "3" ["WORK_CODE"]=> string(1) "3" [2]=> NULL ["MHR"]=> NULL [3]=> NULL ["PHR"]=> NULL [4]=> NULL ["PESO_VALUE"]=> NULL }
[2]=> array(10) { [0]=> string(1) "1" ["LABOR_NO"]=> string(1) "1" [1]=> string(1) "3" ["WORK_CODE"]=> string(1) "3" [2]=> string(4) "2.50" ["MHR"]=> string(4) "2.50" [3]=> string(4) "0.00" ["PHR"]=> string(4) "0.00" [4]=> string(7) "3000.00" ["PESO_VALUE"]=> string(7) "3000.00" }
}
继承人我所做的但是没有工作我想。我不知道=>
一直在继续将它们变为$keys
..
include('MySQLHandler.php');
class Displayer extends MySQLHandler {
public function getTitle($batchNo = NULL,$workCode = NULL){
$this->init();
$STMT="SELECT REC_NO,PARTS_WORKSCOPE FROM RAPID_TEMP_ESTIMATE_V3 WHERE BATCH_NO={$batchNo} AND WORK_CODE={$workCode} AND PARTS_WORKSCOPE_TYPE='Workscope:'";
$DATA=$this->Select($STMT);
// create array of data subjects..
$result = array();
$result['REC_NO'] = $DATA[0]['REC_NO'];
$result['PARTS_WORKSCOPE'] = $DATA[0]['PARTS_WORKSCOPE'];
return $result;
}
public function getTotal($batchNo = NULL,$workCode = NULL){
$this->init();
// par selection
$STMT="SELECT PAR_VALUE FROM RAPID_PAR WHERE PAR_NAME='LABOR_RATE_PER_HOUR'";
$DATA = $this->Select($STMT);
$PAR_VALUE = $DATA[0]['PAR_VALUE'];
// rollup
$STMT="SELECT LABOR_NO,WORK_CODE,MHR,PHR,PESO_VALUE FROM RAPID_TEMP_ESTIMATE_V3 WHERE BATCH_NO={$batchNo} AND WORK_CODE={$workCode} ORDER BY MINOR_WORK_CODE, WORK_CODE_ORDER";
$DATA=$this->Select($STMT);
foreach($DATA as $key=>$value){
foreach($value as $fieldset=>$values){
echo $fieldset.'<br/>';
}
}
}
}
$displayer = new Displayer;
$displayer->getTotal(18,3);