问题描述:

I am new in laravel 5, I want to access student list who are in class 10,

Suppose you have a student table and have all class students.

I want to pass class id using select box and then want all student list in result div using jquery in laravel 5...

网友答案:

You can use ajax call for this on selectbox change event and then create the php script for the ajax call like below

If your table name is like students with example columns call_id,student_id,name, other columns

then code should be

$students = DB::table('students')->where('call_id', 10)->get();

you can traverse the students like

$html = '';
foreach ($students as $student)
{
    // create your html for required fields to display
    $html = '<div> Student Name :'.$student->name.'</div>';
}
echo $html;

and display this returned ajax response in your target div.

you will get result

相关阅读:
Top