【问题标题】:Grocery Crud display image from another tableGrocery Crud 显示来自另一张桌子的图像
【发布时间】:2016-07-29 09:05:00
【问题描述】:

我正在尝试在另一张桌子上的杂货杂货编辑中显示图像。已经提供了它只是显示文件名而不是图像的关系。 下面是我的代码,让我知道我需要纠正的地方。也不想更新我的编辑表(inwardinventory)中的图像。只需要根据从 mastersku 表中选择的 sacoskucode 列来显示它。

            public function entry()
                {
                        $crud = new grocery_CRUD();

                        //$crud->set_theme('datatables');
                        $crud->unset_delete();

                        $crud->set_table('inwardinventory');
                        $crud->set_primary_key('SacoSku','inwardinventory');
                        $crud->set_relation('SacoSku','mastersku','SacoSku');
                        $crud->set_relation('PdtImage','mastersku','PdtImage');
                        $crud->set_field_upload('PdtImage','assets/uploads/files');
                        $crud->set_subject('In Out Stock');
                        $crud->field_type('TranscationType','dropdown',
                        array('IN' => 'Inward / Purchase','OUT' => 'Out Ward / Sale / Basement'));
                        $output = $crud->render();

                        $this->_example_output($output);
            }   

【问题讨论】:

    标签: php codeigniter-2 grocery-crud


    【解决方案1】:

    您可以提供带有问题的表格结构,以便为您提供准确的答案;

    • 根据杂货店网站的文档 set_relation 函数 接受参数:

    set_relation($field_name ,$related_table,$related_title_field)

    如果您的数据库架构是这样的:

    tblOne(id, refImageID)
    

    集合关系函数一定是这样的:

    $crud->set_relation('refImageID','tblImage','imagePath');
    
    • 为避免编辑图像并仅显示它添加行

    $crud->fields(array("feilds", "to", "edit"));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-09
      • 2020-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-25
      • 2015-06-20
      相关资源
      最近更新 更多