Today, We want to share with you laravel dropdown from database.In this post we will show you create dropdown from database value selected in laravel., hear for how to show select box with selected option dynamically in laravel. we will give you demo and example for implement.In this post, we will learn about How To Show Selected Value From Database In Dropdown Using Laravel? with an example.
how to retrieve data from database whenever select in drop down list in laravel?
Controller Code
/** * Show records * * @return \Illuminate\Http\Response */ public function dropDownShow(Request $request) { $outputs = Item::pluck('name', 'id'); $selectedID = 2; return view('outputs.edit', compact('id', 'outputs')); }
Example 1 : Using Form
{!! Form::Label('item', 'Item:') !!} {!! Form::select('item_id', $outputs, $selectedID, ['class' => 'form-control']) !!}
Example 2 : Without Using Form
I hope you get an idea about create dynamic select box with Form class.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.