【问题标题】:show grocery crud using tab panel使用标签面板显示杂货杂货
【发布时间】:2012-07-27 18:04:11
【问题描述】:

我是杂货杂货的新手。我有一个数据库表,可以说 customer_details,它包括 customer_name 和 customer_id 等列。我有另一个名为 purches_details 的表,customer_id 是该表的外键。

我想根据 customer_detail 表中的 customer_name 列在我的视图中创建一个选项卡面板(菜单)。标签名称应该是客户名称

& 当有人单击相关的 customer_name 选项卡时,相关的购买详细信息应显示为杂货杂货网格。

请朋友们帮帮我,我非常想要。

谢谢。

【问题讨论】:

    标签: codeigniter grocery-crud


    【解决方案1】:

    我得到了这个答案……

    the controller from grocery CRUD 1.2.3 with CodeIgniter 2.1.2 (! try to use CI 2.1.2 or CI 2.1.0 versions + latest grocery CRUD):
    
    
                <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');    
            class Examples extends CI_Controller {    public function __construct()
                {
                  parent::__construct();
                  $this->load->database();
                  $this->load->helper('url');
                  $this->load->library('grocery_crud');
                }    
            public function _example_output($output = null)
                {
                  $this->load->view('example', $output);
                }    public function index()
                {
                  $this->_example_output( (object) array('output' => '', 'js_files' => array(), 'css_files' => array()));
                }    
            public function customers()
                {
                  $crud = new grocery_crud();
                  $crud->set_table('customer_details');
                  $crud->set_subject('Customer Details');
                  $output = $crud->render();
                  $output->menu = $this->db->select('customer_id, customer_name')->get('customer_details')->result();
                  $this->_example_output($output);
                }    public function purches_details($customer)
                {
                  $company = $this->uri->segment(3);
                  $crud = new grocery_crud();
                  $crud->set_table('purches_details');
                  $crud->set_subject('Purches Details');
                  $crud->where('customer_id', $customer);
                  $output = $crud->render();
                  $output->menu = $this->db->select('customer_id, customer_name')->get('customer_details')->result();
                  $this->_example_output($output);
                }    
            }
    
    and the view with our customer names links:
    
                [CODE]
                <!DOCTYPE html>
                <html>
                <head>
                <meta charset="utf-8" />
                <?php
                foreach($css_files as $file): ?>
                <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
                <?php endforeach; ?>
                <?php foreach($js_files as $file): ?>
                <script src="<?php echo $file; ?>"></script>
                <?php endforeach; ?>
                <style type='text/css'>
                body
                {
                font-family: Arial;
                font-size: 14px;
                }
                a {
                    color: blue;
                    text-decoration: none;
                    font-size: 14px;
                }
                a:hover
                {
                text-decoration: underline;
                }
                </style>
                </head>
                <body>
                <div>
                <?php echo anchor('examples/customers', 'All Customers');?> :
                <?php foreach ($menu as $link) {?>
                  <?php echo anchor("examples/purches_details/$link->customer_id", "$link->customer_name");?> &middot;
                <?php }?>
                </div>
                <div style='height:20px;'></div>
                    <div>
                  <?php echo $output; ?>
                    </div>
                </body>
                </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-28
      • 1970-01-01
      • 2013-10-24
      相关资源
      最近更新 更多