データベースからデータを取得するテーブルがあり、すべての行を一度に更新する必要があります。各セルの内部には入力フィールドが追加されています。今私はデータを入力するときに一度にすべてのユーザーを更新できるようにしたいが、私は方法を知らない。以下は複数のテーブル行を一度に保存する(Laravel 4)
は、私の見解の写真です:あなたの入力要素が$row->id
をキー配列、する必要があります(私はこれがある
@extends('admin/master')
@section('content')
<section class="content">
{{Form::open()}}
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<div class="col-lg-4">
<h3 class="box-title">INPUT EXAM RESULTS FOR EACH STUDENT: </h3>
</div>
<div class="pull-right col-lg-8">
<div class="col-lg-2 col-lg-offset-5 pull-left">
<select class="btn bg-navy" name="city" >
<option>Select City</option>
<option>Prishtin</option>
<option>Prizren</option>
</select>
</div>
<div class="col-lg-5 pull-right">
<div class="input-group">
<input type="text" name="search_input" class="form-control" placeholder="Search here...">
<div class="input-group-btn">
<button type="submit" class="btn btn-info"><i class="fa fa-search"></i> Search</button>
</div>
</div>
</div>
</div>
</div>
<div class="box-body">
<?php if (isset($data)) { ?>
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>{{Lang::get('messages.stid')}} </th>
<th>{{Lang::get('messages.name')}}</th>
<th>Subject 1</th>
<th>Subject 2</th>
<th>Subject 3</th>
<th>Subject 4</th>
</tr>
</thead>
<tbody>@foreach ($data as $row)
<tr>
<td>{{$row->id}}</td>
<td>{{$row->fname}} {{$row->lname}}</td>
<td><input type="text" name="sub1" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub2" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub3" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub4" class="form-control" placeholder="Add marks here..."></td>
</tr>
@endforeach
</tbody>
</table>
<button type="submit" class="col-lg-2 pull-right btn btn-success"><i class="fa fa-save"></i> Save</button>
<?php } ?>
</div>
</div>
</div>
</div>
{{Form::close()}}
</section>
{{ HTML::script('/admin/assets/js/jquery-2.2.3.min.js') }}
{{ HTML::script('/admin/assets/js/bootstrap.min.js') }}
{{ HTML::script('/admin/assets/js/jquery.dataTables.min.js') }}
{{ HTML::script('/admin/assets/js/dataTables.bootstrap.min.js') }}
<script>
$(function() {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
@stop
//コントローラ
public function search_input(){
$input = Input::get('search_input');
$city = Input::get('city');
$data = Apply::where('exam_venue', '=', "$input")
->where('city_applied', '=', "$city")->get();
if (isset($_POST['save'])) {
}
return View::make('admin/exam/edit',compact('data'));
}
すべての行を一度に更新すると、検索入力が使用されるときを意味すると思いますか?その場合、サーバー側の処理を設定し、ajaxを介してデータテーブルのデータを要求する必要があります。または、毎回フォームを送信して、ページ全体を再読み込みしていますか? – btl
はい。しかし、私はそれが良いと思うajaxのcuzでそれを行う方法を知らない –
あなたが知っているので、このパッケージは、サーバー側の処理を処理する優れた仕事を行います。私は多くのプロジェクトでそれを使用しています:https://github.com/yajra/laravel-datatables – btl