开发者

theme_table with multiple rows

I have the following 2 array's, I want them display in a table. The problem is he prints 1 value 20 times to my screen. I added a for loop but didn't solve my problem? What could be the reason?

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;


This is just a quick exemple to use theme_table() in drupal.

$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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜