douxiezha9319
douxiezha9319
2019-06-24 09:10
浏览 41
已采纳

当我点击codeigniter中的按钮时,如何调用页面?

I am not calling a page in codeiginiter when i click button..

i am new in this so please HELP....

<a href="#"><i class="fa fa-check-square-o nav_icon"></i>Forms<span class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
    <li>
        <a href="<?php echo base_url('application/views/middlepage/inputs.php'); ?>">Inputs</a>
    </li>
    <li>
        <a href="<?php echo base_url('application/views/middlepage/validation.php'); ?>">Form Validation</a>
    </li>
</ul>

on theme implement in codeiginiter i can't call the page it's is show the page was not found but i given correct path on it.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duanbi7204
    duanbi7204 2019-06-24 10:49
    已采纳

    First you have to understand MVC Architecture..

    You just have to call Controller/Method where you call your view. example:

    Controller

    <?php
    
    class Mycontroller extends CI_Controller{
       public function orders(){
         $this->load->view('orderpage');
       }
    }
    
    ?>
    

    view - Orderpage.php

    <body>
    <h3>orders list</h3>
    </body>
    

    your just have to add anchor tag like

    <a href="<?php echo base_url('mycontroller/orders');?>">Go to orders</a>
    
    点赞 评论
  • douzhi8488
    douzhi8488 2019-06-24 10:17

    Edit config/config.php file

    $config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/codeigniter/';

    in view

    <a href="<?php echo base_url('Controller_name/function_name'); ?>">Inputs</a>

    点赞 评论
  • doushui3216
    doushui3216 2019-06-24 12:40

    you need to setup routs for View go to

    \application\configoutes.php

    and add a route at the end like this

    $route['ViewName'] = 'ViewPath';
    

    My views are presented in

    application\views\user

    so i will add

    $route['confirm'] = 'user/confirm';
    
    点赞 评论

相关推荐