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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。