Php 将数据按行传递给控制器
我有一个表显示,每行包含一个按钮。使用这个按钮,我必须将id传递给控制器,在那里使用这个管理员可以逐个查看用户详细信息Php 将数据按行传递给控制器,php,html,laravel-4.2,Php,Html,Laravel 4.2,我有一个表显示,每行包含一个按钮。使用这个按钮,我必须将id传递给控制器,在那里使用这个管理员可以逐个查看用户详细信息 <table id="example2" class="table table-bordered table-hover" style="text-align: center"> <thead> <tr> <th>Applicant ID</th>
<table id="example2" class="table table-bordered table-hover" style="text-align: center">
<thead>
<tr>
<th>Applicant ID</th>
<th>Full name</th>
<th>Position applied</th>
<th>Date & time applied</th>
<th>View CV</th>
</tr>
</thead>
<tbody>
@foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td>
<button type="submit" class="btn btn-
default" name="viewcv"> View</button> <br>
<br>
</td>
</tr>
@endforeach
</tbody>
</table>
申请人ID
全名
职位申请
应用的日期和时间
视图CV
@foreach($job作为$row应用)
{{$row->app_id}
{{$row->fullname}
{{$row->position}
{{$row->created_at}
查看
@endforeach
请检查代码,希望它有助于:
<table id="example2" class="table table-bordered table-hover" style="text-align: center">
<thead>
<tr>
<th>Applicant ID</th>
<th>Full name</th>
<th>Position applied</th>
<th>Date & time applied</th>
<th>View CV</th>
</tr>
</thead>
<tbody>
@foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td><a href="path/to/your/controller/{{$row->id}}">CV</a></td>
</tr>
@endforeach
</tbody>
</table>
申请人ID
全名
职位申请
应用的日期和时间
视图CV
@foreach($job作为$row应用)
{{$row->app_id}
{{$row->fullname}
{{$row->position}
{{$row->created_at}
@endforeach
假设您希望传递字段“id”或根据需要更改它。如果您希望链接到
显示视图,请尝试以下操作:
@foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td>
<a href="{{action('JobController@show', $row->id)}}" class="btn btn-default">View</button>
</td>
</tr>
@endforeach
只需将记录的id传递给控制器函数,并从数据库中获取详细信息
<td>
<a href="{{URL::route('routeName',$row->app_id)}}" class="btn btn-default" name="viewcv"> View</a> <br>
</td>
你的问题是什么…?你想让用户进入“显示”视图或类似的视图吗?不知道如何传递每个用户的id如果你想重定向,那么使用锚定标记而不是提交按钮,通过这种方式,你将很容易在链接中添加ID。你能推荐一些示例吗?我创建了这个方法,但不知道如何在“提交视图”按钮上运行。公共函数viewontable(Request$Request,$id){$user=Apply::where('user_id',$id)->first();if(!$user){return View::make('createcv',array('message'=>'必须首先创建您的简历才能查看。!');}否则{$data=Apply::where('user_id',$id)->get()$applicator\u id=Apply::where('user\u id',$id)->pull('id');$language=language::where('app\u id',$applicator\u id)->get();$skills=skills::where('app\u id',$applicator\u id)->get();return View::make('pdf\u report/html\u resume',compact('data','language','skills');}如果只想将用户重定向到show视图,则不需要创建按钮并提交表单。只需要一个锚。
<td>
<a href="{{URL::route('routeName',$row->app_id)}}" class="btn btn-default" name="viewcv"> View</a> <br>
</td>