具有多行的 theme_table
我有以下 2 个数组,我希望它们显示在表格中。问题是他在我的屏幕上打印了 1 个值 20 次。我添加了 for 循环但没有解决我的问题?可能是什么原因?
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是Drupal中使用
them_table()
的快速范围。This is just a quick exemple to use
theme_table()
in drupal.