nikhil_lu210
1 year ago

How to Get Value/Data in dropdown options, that I have inserted into table...?

Posted 1 year ago by nikhil_lu210

This is my code from allbus.create file:

Route No.
    <select name="routeNo" id="" class="{{ $errors->has('routeNo') ? ' is-invalid' : '' }}" required>
        <option value="">Select Route No.</option>
        <option value="01">01</option>
        <option value="02">02</option>
        <option value="03">03</option>
        <option value="04">04</option>
    </select>

    @if ($errors->has('routeNo'))
    <span class="invalid-feedback" role="alert">
              <strong>{{ $errors->first('routeNo') }}</strong>
    </span> 
@endif 

</div>

Now I want to get values from the database table where I have inserted Route No. from allroute.create file.

I Have tried to get those values in this way:

Route No.
    <select name="routeNo" id="" class="{{ $errors->has('routeNo') ? ' is-invalid' : '' }}" required>
        <option value="">Select Route No.</option>
        <option value="{{ $allbus->routeNo }}">{{ $allbus->routeNo }}</option>
    </select>

    @if ($errors->has('routeNo'))
    <span class="invalid-feedback" role="alert">
          <strong>{{ $errors->first('routeNo') }}</strong>
    </span> 
@endif 

</div>

But I get this error:

"Undefined variable: allbus (View: C:\laragon\www\tManagement\resources\views\allbus\create.blade.php)"

Can anyone tell me the process properly...?

Please sign in or create an account to participate in this conversation.