如何从Excel中获取数据以进行数据库查询

时间:2019-07-11 12:50:33

标签: database laravel maatwebsite-excel

我使用maatwebsite excel将数据添加到数据库中。但是现在,我必须从excel中获取行,然后用户将从下拉列表中选择“ id”。如何插入此“ id”和从excel获取的行?

我已经在数据库中创建了从Excel导入的行,但是我没有用这种方法解决问题。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="post" enctype="multipart/form-data" data-toggle="validator" action="{{route("import_eslendirme")}}">
  <input type="hidden">{{csrf_field()}}
  <div class="box-body">
    <div class="custom-select">
      <select name="turnuva_id" class="form-control" >
        <option value="0" style="background-color: black">Turnuva Seç</option>
        @foreach($turnuvalar as $turnuva)
        <option value="{{$turnuva->id}}">{{$turnuva->adi}}</option>
        @endforeach
      </select>
    </div>
    <div class="custom-select">
      <select name="tur_sayisi" class="form-control">
        <option value="0" style="background-color: black">Tur</option>
        @for($i=0;10>=$i;$i++)
        <option value="{{($i+1)}}    ">{{($i+1)}}</option>
        @endfor
      </select>
    </div>
    <div class="form-group">
      <label for="file">Dosya Seçiniz</label>
      <p>   </p>
      <input type="file" id="file" name="file">
      <p>   </p>
      <p class="help-block">Lütfen Eşleştirme Excel Dosyasını Seçiniz</p>
    </div>
  </div>
  <!-- /.box-body -->
  <div class="box-footer">
    <button type="submit" class="btn btn-primary" class="zaman">Eşleştir</button>
  </div>
</form>

0 个答案:

没有答案