这是我发现自己几次的情况,我只想彻底清除它。使用Code Igniter控制器创建foreach循环并查看
最好只是告诉你我需要在一些示例代码中做什么。
我的控制器
function my_controller()
{
$id = $this->uri->segment(3);
$this->db->from('cue_sheets');
$this->db->where('id', $id);
$data['get_cue_sheets'] = $this->db->get();
$this->db->from('clips');
$this->db->where('sheet_id', ' CUE SHEET ID GOES IN HERE ??? ');
$data['get_clips'] = $this->db->get();
$this->load->view('show_sheets_and_clips', $data);
}
我查看
<?php if($get_cue_sheets->result_array()) { ?>
<?php foreach($get_cue_sheets->result_array() as $sheetRow): ?>
<h1><?php echo $sheetRow['sheet_name']; ?></h1>
<br/>
<?php if($get_clips->result_array()) { ?>
<ul>
<?php foreach($get_clips->result_array() as $clipRow): ?>
<li><?php echo $clipRow['clip_name']; ?></li>
<?php endforeach; ?>
</ul>
<?php } else { echo 'No Clips Found'; } ?>
<?php endforeach; ?>
<?php } ?>
所以基本上我想显示张数,然后在每个这些表属于该剪辑的片。
我希望这对那里的人有意义。
感谢,
添
有趣。不幸的是,当我实施您的解决方案时,我收到以下错误。解析错误:语法错误,意外的T_FUNCTION,期待')' – Tim 2010-06-15 02:20:24
@Tim:上面只会在php 5.3或更高版本中工作。 – azatoth 2010-06-15 18:05:27