dpzbzp8728 2017-01-10 14:22
浏览 38

如何在codeigniter中包含一个文件

Hy, I have a page on my site, with the name of hotels. here is the code of the hotel page.

here is my controller:

function country_holiday(){
    $data['hotels']= $this->Travel->holiday();
    $this->load->view('hotels', $data);
}

here is my model:

function holiday(){
    $this->db->select();
    $this->db->from('holidays_hotel_2');
    $this->db->order_by('rand()');
    $this->db->limit(16);   
    $query= $this->db->get();                   
    return $query->result_array();
}

I am getting my required data on hotel page and its working fine, I want to include this hotel page into my another page(hotelling program).

I used where i want to placed that hotel in hotelling program page, but it did not show up any detail except the html of hotel page. what should i need to do. Any Idea??

  • 写回答

2条回答 默认 最新

  • doujing5150 2017-01-19 14:11
    关注

    As far as I understood the problem, you want to include your hotel page into hotelling page. Which means you want to call a view inside another view. Yes you can.

    In your controller,

    function country_holiday(){
        $data['hotels']= $this->Travel->holiday();
        $this->load->view('hotelling', $data);
    }
    

    in your view (hotelling.php),

    <html>
      <head>
        <title></title>
      </head>
      <body>
         <?php $this->load->view('hotels', $hotels); ?>
      </body>
    </html> 
    

    But i'm not sure about the downside of doing this. But it'll work.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号