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

将值从表传递到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 VS2022 C++的相关代码问题咨询
  • ¥15 如果要做一个老年人平板有哪些需求
  • ¥15 k8s生产配置推荐配置及部署方案
  • ¥15 matlab提取运动物体的坐标
  • ¥15 人大金仓下载,有人知道怎么解决吗
  • ¥15 一个小问题,本人刚入门,哪位可以help
  • ¥30 python安卓开发
  • ¥15 使用R语言GD包一直不出结果
  • ¥15 计算机微处理器与接口技术相关问题,求解答图片的这个问题,有多少个端口,端口地址和解答问题的方法和思路,不要AI作答
  • ¥15 如何根据一个截图编写对应的HTML代码