@mohammedkamar How do you print the student name?
Can you show your blade code?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
public function index(){
$books = DB::table('libraries')->join('students','libraries.stu_id','=','students.id')->select('libraries.*','students.name')->get();
$students = DB::table('students')->select('*')->get(); // To get Student List from Students table
return view('db.index' , compact('students','books'));
}
@mohammedkamar Update your query like this:
$books = DB::table('libraries')
->join('students', 'libraries.stu_id', '=', 'students.id')
->select('libraries.*', 'students.name as student_name')
->get();
Now update your blade:
@foreach ($books as $book)
Book_id: {{ $book->id }}
Student Name: {{ $book->student_name }} |
Book Name: {{ $book->book }} |
Status: {{ $book->status }} |
<a href="{{ route('deleteBookRoute', $book->id) }}">Delete</a>
@endforeach
Please or to participate in this conversation.