당신의 $ 로그가 거짓 없다 내 스크립트
public function projectReport($ID){
$get_con = $this->getConnection();
$result = mysql_query($query, $get_con);
$rep = new stdClass();
if(false !== $result){
$multis = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$count = new stdClass();
$count->Boys = (int)$row['males'];
$count->Girls = (int)$row['females'];
$multis[] = $count;
}
$rep->multiples = $multis;
}
return $rep;
}
report.php 함수 본문은 그래서 당신은 그것을 확인 할 필요가 없습니다. 또한 다중 속성이 누락되었을 수 있습니다.
이 시도 :
$report = new Report();
$log = $report->projectReport($ID);
if(property_exists($log, 'multiples')){ //check if multiples attribute exists
foreach ($log->multiples as $m) //walk through every multiples record
{
$Boys = $m->Boys; //get Boys and Girls attributes values and print them
$Girls = $m->Girls;
print_r($Boys);
print_r($Girls);
}
}
나는 그것이 당신이 달성 싶은 게 아니에요 확신 해요,하지만 당신이 지금까지있어 내용에 따라 작동합니다 어떻게.
$ mat은 무엇입니까? $ multfs는 $ multis의 철자가 틀린 버전입니까? 당신의 방법은 무엇을 반환합니까? $ log를 stdClass 객체로 사용하지만 메소드의 결과에 따라 배열이나 다른 것일 수 있습니다. 명확히하십시오. – MaGnetas
죄송합니다 ... 실수로 코드를 편집했습니다 ... –
'projectReport'는 값을 반환하지 않습니다 ... –