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 qc代码,修改和添加东西
  • ¥50 Unity的粒子系统使用shadergraph(内置管线)制作的一个顶点偏移shader,但是粒子模型移动时,顶点也会偏移
  • ¥15 如何用python处理excel的数据(极值标准化)
  • ¥15 三向应力状态求剪应力
  • ¥15 jupyter notebook如何添加libGL.so.1库
  • ¥20 easyPoi能否实现下拉多选或者复选框
  • ¥15 网桥在转发帧时,会变帧的源地址和目的地址吗?
  • ¥15 用Multisim设计汽车尾灯控制电路
  • ¥100 求用matlab求解上述微分方程的程序代码