|
楼主 |
发表于 2009-11-21 13:02:56
|
显示全部楼层
回复 5# longjianghu
我还是不太理解:
看下如下代码,怎么有错?
controllers:
function index() {
$data['page_title'] = '基于PHP架框新闻发布系统(学习版)';
$data['page_logo'] = '迅捷新闻发布系统';
$this->load->model('Mnews');
$data['CategoryName'] = $this->Mnews->category();
$data['newsinfo'] = $this->Mnews->newsinfo();
$this->load->view('header',$data);
$this->load->view('index',$data);
$this->load->view('footer');
}
models:
function category() {
$query = $this->db->get('categories');
return $query->result();
}
function newsinfo() {
$query = $this->db->query("select * from categories, newsinfo where categories.CategoryID=newsinfo.CategoryID ");
return $query->result();
}
viewS:
<div id="content">
<?php foreach ($CategoryName as $row):?>
<div class="class">
<h1><?php echo anchor('news/get_category/'.$row->CategoryID,$row->CategoryName);?><p align="right"><?php echo anchor('news/get_category/'.$row->CategoryID,'更多'.$row->CategoryName);?></p></h1>
<ul>
<?php foreach($newsinfo as $row):?>
<li><?php echo anchor('news/content/'.$row->NewsID,$row->Title);?><span style="font-size:16px;"><?php echo '['.$row->IssueTime.']';?></span></li>
<?php endforeach;?>
</ul>
</div>
<?php endforeach;?>
<div style="clear:both;"></div>
</div> |
|