HTML:<label>place</label> <select class="form-control" name="provice" id="provice"> <option value="0">test</option> @foreach ($provincees as $key => $value) <option value="{{ $value->id }}">{{ $value->name }}</option> @endforeach</select>我想獲取數(shù)據(jù)名稱并插入數(shù)據(jù)庫(kù),使用在選擇選項(xiàng)中找到的 id 搜索省名。我用它來根據(jù)選擇的 id 獲取名稱:$results = DB::select('select name from provincees where id = ?',$request->provice);我有用于插入數(shù)據(jù)的代碼: $i=DB::insert("INSERT INTO place (id,name) VALUES (?,?,?,?) ",[$request->provice,$results]);有沒有人可以幫我解決這個(gè)問題?
從 laravel 獲取數(shù)據(jù)選項(xiàng)
紅糖糍粑
2023-03-03 10:14:29