Php 拉威尔问题中通过复选框获取数据
我试图使用Laravel中的两个独立查询从两个不同的表中获取数据。但我想用两个不同的复选框显示这两个表数据,例如,如果我想查看出版物详细信息或教育详细信息或两者,请帮助我如何处理视图 我的代码如下所示: 控制器代码是ExampleController.phpPhp 拉威尔问题中通过复选框获取数据,php,mysql,laravel,Php,Mysql,Laravel,我试图使用Laravel中的两个独立查询从两个不同的表中获取数据。但我想用两个不同的复选框显示这两个表数据,例如,如果我想查看出版物详细信息或教育详细信息或两者,请帮助我如何处理视图 我的代码如下所示: 控制器代码是ExampleController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; use Auth; class ExampleController exte
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use Auth;
class ExampleController extends Controller
{
public function index()
{
$result = DB::table('education')->get();
$data = DB::table('publications')->get();
return view('triel',compact('result','data'));
}
}
请修改我的视图,通过复选框分别获取这两个结果。有许多方法可以实现您正在尝试的目标。我展示的示例是使用Jquery
添加到您的复选框中。当其中一个复选框被点击时,比如说发布,然后隐藏你的研究细节表。e、 g
$(.checkbox publication”)。单击(函数(){
$(“#研究细节”).css('display','none');
$(“#出版物详细信息”).css('display','block');
});代码>
@extends('layouts.app')
@section('content')
<div class="container"><br>
<h1>Irfan Khan Triel Page</h1>
<div class="text text-success text-center">
PHD Research
</div>
<table class="table">
<tr>
<th>
PHD Research Area
</th>
<th>University</th>
<th>Country</th>
</tr>
@foreach($result as $value)
<tr>
<td>{{$value->research_area}}</td>
<td>{{$value->univ}}</td>
<td>{{$value->country}}</td>
</tr>
@endforeach
</table>
<div class="text text-success text-center">
Publications Detail
</div>
<table class="table">
<tr>
<th>
Title
</th>
<th>Status</th>
<th>Year</th>
</tr>
@foreach($data as $value)
<tr>
<td>{{$value->title}}</td>
<td>{{$value->status}}</td>
<td>{{$value->year}}</td>
</tr>
@endforeach
</table>
@endsection
Route::get('triel','ExampleController@index');