dtjzpg5313 2019-03-08 03:50
浏览 117
已采纳

将值从表传递到Laravel中的另一个页面

I have a table with data showed from the MySQL database.

Here is my controller:

function getData() {
        $data['data'] = DB::table('act_hi_procinst')->get();

        if(count($data) > 0) {
            return view('datatracking', $data);
        } else {
            return view('datatracking');
        }
}

Here is my view:

@foreach($data as $data)
    <tr>
        <td><a href= "{{ url('/') }}"> {{ $data -> ID_ }}</a></td>
        <td>{{ $data -> PROC_INST_ID_ }}</td>
        <td>{{ $data -> BUSINESS_KEY_ }}</td>
        <td>{{ $data -> PROC_DEF_ID_ }}</td>
        <td>{{ $data -> START_TIME_ }}</td>
        <td>{{ $data -> END_TIME_ }}</td>
        <td>{{ $data -> DURATION_ }}</td>
        <td>{{ $data -> START_USER_ID_ }}</td>
        <td>{{ $data -> START_ACT_ID_ }}</td>
        <td>{{ $data -> END_ACT_ID_ }}</td>
        <td>{{ $data -> SUPER_PROCESS_INSTANCE_ID_ }}</td>
        <td>{{ $data -> DELETE_REASON_ }}</td>
        <td>{{ $data -> TENANT_ID_ }}</td>
        <td>{{ $data -> NAME_ }}</td>
    </tr>
@endforeach

I use href tag to make my first column into a link. I want when I click it, it will go to other page and passing the ID_ value to that page. I have no idea how to write it in Laravel.

  • 写回答

2条回答 默认 最新

  • dph6308 2019-03-08 03:56
    关注

    You can add it's value into URL and can get it through a query string

    @foreach($data as $data)
         <tr>
             <td><a href= "{{ url('/') }}?id={{ $data -> ID_ }}"> {{ $data -> ID_ }}</a></td>
             <td>{{ $data -> PROC_INST_ID_ }}</td>
             <td>{{ $data -> BUSINESS_KEY_ }}</td>
             <td>{{ $data -> PROC_DEF_ID_ }}</td>
             <td>{{ $data -> START_TIME_ }}</td>
             <td>{{ $data -> END_TIME_ }}</td>
             <td>{{ $data -> DURATION_ }}</td>
             <td>{{ $data -> START_USER_ID_ }}</td>
             <td>{{ $data -> START_ACT_ID_ }}</td>
             <td>{{ $data -> END_ACT_ID_ }}</td>
             <td>{{ $data -> SUPER_PROCESS_INSTANCE_ID_ }}</td>
             <td>{{ $data -> DELETE_REASON_ }}</td>
             <td>{{ $data -> TENANT_ID_ }}</td>
             <td>{{ $data -> NAME_ }}</td>
         </tr>
    @endforeach
    

    In your controller, you can get value like:

    public function yourfuncName(Request $request)
    { 
        $id =  $request->get('id');
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集