/ 这是模型 /
<?php
class home_model extends CI_Model
{
public function store()
{
$this->db->select('storename');
$q=$this->db->get('stores');
return $q;
}
}
?>
/ 这是控制器 /
class Home_controller extends CI_Controller {
public function __construct() {
parent::__construct();
$this->_data = array();
}
public function index()
{
$this->load->model('home_model');
$qu=$this->home_model->store();
$data['query']=$qu;
$data['main_content'] = 'frontend/home/home';
$this->load->view('frontend/master_layout', $data);
}
public function selected()
{
$data['main_content'] = 'frontend/home/selected';
$this->load->view('frontend/master_layout', $data);
}
}
/ 这是View,我想使用base_url() /
在每个商店名称创建一个锚标记 <div class="home_right">
<?php
echo "<br>";
echo "<br>";
foreach($query->result() as $row)
{
echo "<br>".$row->storename."<br>";
}
?>
</div>
答案 0 :(得分:2)
只有echo
这样的锚标签
<div class="home_right">
<?php
echo "<br>";
foreach($query->result() as $row)
{
echo "<a href=".base_url().$row->storename.">".$row->storename ."</a><br>";
}
?>
</div>