0

I want to create a form with a drop down menu in which items from an oracle table. How can I do that? The connection with db, deendencies, csrf fields are all ok, but I'm a little bit stuck!

My controller excerpt with the query I want is this:

public function secondform()
    {
        $spoudes = DB::table('prog_title') -> select('pr_title')-> where('pr_index', '=', 1)->get();
        return view ('kedivimform2', ['programmata' => $spoudes]);

and my blade (kedivimform2) below. How should I integrate $programmata as drop down into my form?

<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>
Konstantinos
  • 51
  • 1
  • 14
  • 1
    Possible duplicate of [Laravel-5 how to populate select box from database with id value and name value](https://stackoverflow.com/questions/29508297/laravel-5-how-to-populate-select-box-from-database-with-id-value-and-name-value) – Nico Haase Feb 06 '19 at 09:46

1 Answers1

0

I finally figured out myself a solution and I add my code excerpts in case someone works on similar projects.

1) Controller:

 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) Blade (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>
Konstantinos
  • 51
  • 1
  • 14