我想创建一个带有下拉菜单的表单,其中包含来自oracle表的项。我怎样才能做到这一点?与db,endendencies,csrf字段的连接都可以,但是我有点卡住了!
我要查询的控制器摘录是这样:
public function secondform()
{
$spoudes = DB::table('prog_title') -> select('pr_title')-> where('pr_index', '=', 1)->get();
return view ('kedivimform2', ['programmata' => $spoudes]);
和下面的我的刀片(kedivimform2)。我应该如何将$ programmata集成到表单中?
<form method='post' action="/kedivimtest2">
{{csrf_field()}
<label>
Lessons<font color="red">*</font> <br>
<input name='titlos' type='text' minlength="5" required> <!-- I want a drop menu here! -->
</label>
<input type='submit' value="OK!">
</form>
答案 0 :(得分:0)
我终于想出了解决方案,并添加了代码摘录,以防有人从事类似项目。
1)控制器:
public function secondform()
{
//return view ('kedivimform2');
$spoudes = DB::table('prog_title') -> select('pr_title')-> where('pr_index', '=', 1)->get();
return view ('kedivimform2', ['programmata' => $spoudes]);
}
2)剑(kedivimform):
<form method='post' action="/kedivimtest2">
{{csrf_field()}
<label>
<select name="titlos" required>
@foreach ($programmata as $program)
<option value="{{$program -> pr_title}}">{{$program->pr_title}}</option>
@endforeach
</select>
</label>
<input type='submit' value="OK!">
</form>