|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2012-5-22 15:35:29
|
显示全部楼层
Hex 发表于 2012-5-22 13:45 ![](static/image/common/back.gif)
把你的代码都贴上来看看吧。
<?php
class Test extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
model
<?php
class Test_models extends CI_Model {
function __construct()
{
parent::__construct();
}
function get_all()
{
$mum=rand(8,15);
$sql = "SELECT * FROM links ORDER BY rand() LIMIT $mum;";
$query=$this->db->query($sql);
return $query->result();
}
}
$this->load->library('pagination');
}
function index()
{
$this->load->model('test_models');
$data['links'] = $this->test_models->get_all();
$this->load->view('test_view', $data);
}
}
view
<table border="1">
<th>
<?php foreach ($links as $row): ?>
<a herf="<?php echo $row->url ?>"><?php echo $row->title?></a></br>
<?php endforeach; ?>
</th>
</table> |
|