Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Cara Mengatasi Kesalahan Pembaruan Data Ini Di Laravel

Coba ini:

RegViewUpdate.blade.php

<html>
<head>

<body>

<form action="edit/{{$users[0]->id}}" method="post" enctype="multipart/form-data">

{{ method_field('PUT') }}
{{ csrf_field() }}

<div class="form-group">
    <label>Name : *</label>
    <input type="text" class="form-control" name="name" value="{{$users[0]->name}}" required>
  </div>

  <div class="form-group">
    <label>Username : *</label>
    <input type="text" class="form-control" name="username" value="{{$users[0]->username}}" required>
  </div>

  <div class="form-group">
    <label>Password : *</label>
    <input type="password" class="form-control" name="password" value="{{$users[0]->pw}}" required>
  </div>

  <div class="form-group">
    <label>Upload Profile Picture :</label>
    <input type="file" class="form-control-file" name="file_img" aria-describedby="fileHelp">
    <small id="fileHelp" class="form-text text-muted">If U Want , U Can Skip Upload A Profile Picture</small>
  </div>

  <input type="submit" class="btn btn-primary" name="submit" value="Update">

</form>

</body>
</html>

RegViewController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;

class RegViewController extends Controller
{

    public function index()
    {
        return view('RegView');
    }

    public function show($id) {
        $users = DB::select('select * from academic where id = ?',[$id]);
        return view('RegViewUpdate',['users'=>$users]);
    }

    public function edit(Request $request, $id)
    {
        $name = $request->input('name');
        try {
             DB::table('academic')
                  ->where('id', $id)
                  ->update(['name' => $name]);
             echo "Record updated successfully.<br/>";
        }  catch (\Exception $ex) {
             dd($ex);
        }
    }

}

Rute:

Route::get('edit/{id}','[email protected]');
Route::put('edit/{id}','[email protected]');


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Unik, tidak dapat diprediksi, 12 digit, id bilangan bulat

  2. Bagaimana cara membandingkan dua bidang/kolom dalam suatu kondisi?

  3. Membersihkan bidang nomor Telepon di mySql

  4. masalah mysql_insert_id dalam penyisipan data konkurensi

  5. mysql Kesalahan fatal:tidak dapat mengalokasikan memori untuk kumpulan buffer