2011-03-31 3 views
1

다음 2 개의 배열을 가지고 있는데, 테이블에 표시하고 싶습니다. 문제는 그가 내 화면에 1 번 20 번 인쇄한다는 것입니다. for 루프를 추가했지만 문제가 해결되지 않았습니까? 그 이유는 무엇일까요?여러 행을 가진 theme_table

enter code here$header = array(); 
$header[] = array('data' => 'UGentID'); 
$header[] = array('data' => 'Internships'); 
// this big array will contains all rows 
$rows = array(); 
//for($i = 0; $i<=($studentUGentID); $i++) { 
foreach($studentUGentID as $key=>$value) { 
    foreach($internshipNaam as $key2=>$value2) { 
     // each loop will add a row here. 
     $row = array(); 
     // build the row 
     $row[] = array('data' => $value[0]['value']); 
     $row[] = array('data' => $value2); 
     // add the row to the "big row data (contains all rows) 
     $rows[] = array('data' => $row); 
    } 
} 
//} 
$output = theme('table', $header, $rows); 
return $output; 
+0

같은 질문을 3 번이나했습니다. 와우. http://stackoverflow.com/questions/5501402/why-does-each-field-appear-in-a-newrowrow/ http://stackoverflow.com/questions/5498350/theme-table-drupal-development – Haza

+0

어쩌면 내 동료 StackOverflow 설명을 이해하지, 잘하면 내가 답변을 얻고있다. 나는 다시 묻지 않을 것이다. 내 사과. – user001

답변

2

이 드루팔에 theme_table()를 사용하는 그냥 빨리 exemple이다.

$header = array(); 
$header[] = array('data' => 'column1 Title'); 
$header[] = array('data' => 'column2 Title'); 

// this big array will contains all rows 
$rows = array(); 
foreach($MyBigArray as $data) { 
    // each loop will add a row here. 
    $row = array(); 
    // build the row 
    $row[] = array('data' => $data[1]); 
    $row[] = array('data' => $data[2]); 
    // add the row to the "big row data (contains all rows) 
    $rows[] = array('data' => $row); 
} 
print theme('table', $header, $rows); 
+0

나는 결국 당신의 도움으로 (하루 종일 검색하고 시도한 후에) 해결책을 찾았습니다. 당신의 도움이되는 코멘트에 감사드립니다! – user001

+0

마지막 질문입니다. 내 질문을 업데이트했습니다. – user001

관련 문제