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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵