dongwei4444 2017-06-02 04:14
浏览 42
已采纳

在一个函数codeigniter中的不同查询

I use Codeigneter and I make a search function and in my function I want run two diffrent query and I want show them in diffrent table, How I can do that Sorry I can't show the data

This is My code:

My controller

function showDetail(){
        // Retrieve the posted search term.
        $detailTiket = $this->input->get('ticket_id');
        // Use a model to retrieve the results.
        $data["result"]= $this->tracking_model->showDetail($detailTiket);
        $data1["result"]= $this->tracking_model->showDetail2($detailTiket);

        // Pass the results to the view.
        $this->load->view('tracking/tiket_detail',$data,$data1);
    }

My Model

function showDetail($detailTiket)
    {   
        if($detailTiket==""){
            $detailTiket = "";
        }

        $showDetailTiket=$this->db->query("My Query1");

        return $detailTiketDown->result();
        }

function showDetail2($detailTiket)
    {   
        if($detailTiket==""){
            $detailTiket = "";
        }

        $detailTiketDown=$this->db->query("My query2");

        return $detailTiketDown->result();
        }

My view

<table Width='800'>  

        <?php
        foreach($data as $row){?>
<tbody>
    <tr>
        <td><?php echo $row->ticket_id; ?></td>
    </tr>

    <tr>
        <td><?php echo $row->created_time; ?></td>
    </tr>

    <tr>
            <td><?php echo $row->start_IT; ?></td>
    </tr>

<tr>
            <td><?php echo $row->estimasi_selesai; ?></td>
    </tr>

    <tr>
            <td><?php echo $row->name; ?></td>
    </tr>

    <tr>
            <td><?php echo $row->description; ?></td>
    </tr>

    <tr style="background-color: cyan">
            <td><b><?php echo $row->Status; ?></b></td>
    </tr>

    </tbody>
        <?php } ?>
                </table>
                </center>
                </div>



<div>
<table Width='1000'>
<?php foreach($data1 as $rows){ ?>  
<tbody>
        <tr>
            <td><?php echo $rows->Tgl_Waktu; ?></td>
            <td><?php echo $rows->PIC; ?></td>
            <td><?php echo $rows->Tracking_Ticket; ?></td>
            <td><?php echo $rows->Keterangan_Ticket; ?></td>
            <td><?php echo $rows->File_Pendukung; ?></td>
        </tr>
</tbody>
        <?php }?>
        </table>
  • 写回答

1条回答 默认 最新

  • douhuiyan2772 2017-06-02 05:15
    关注

    You can pass data like Associative array to view

    change your controller like this

    Controller:

    $data["result"]= $this->tracking_model->showDetail($detailTiket);
    $data["result1"]= $this->tracking_model->showDetail2($detailTiket);
    
    // Pass the results to the view.
    $this->load->view('tracking/tiket_detail',$data);
    

    view:

    Table1 :

     foreach($result as $row)
      {
         //for first result 
      }
    

    Table2:

    foreach($result1 as $row1)
      {
         //for second result 
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿