我有一個(gè)表,它使用FOREACH LOOP. 當(dāng)我IF ELSE STATEMENT在FOREACH LOOP第一個(gè)循環(huán)中插入另一個(gè)循環(huán)時(shí),第一個(gè)循環(huán)似乎沒(méi)問(wèn)題,td開(kāi)始不再對(duì)齊。這意味著如果值為空,它將隱藏單元格,并且第一個(gè)循環(huán)中的其他值將被推進(jìn)。供您參考,我使用的是不同的服務(wù)器數(shù)據(jù)庫(kù),它們是SQL和MYSQL. SQL 是我的主要數(shù)據(jù)庫(kù),而 mysql 用于插入、更新和刪除表中稱(chēng)為“NOTES”的文本區(qū)域。這是來(lái)自我的控制器的查詢 $getNote1 = DB::connection('mysql')->table('note1')->select('stockcode', 'note')->orderBy('stockcode', 'ASC')->get(); $getNote2 = DB::connection('mysql')->table('note2')->select('stockcode', 'note')->orderBy('stockcode', 'ASC')->get(); $getNote3 = DB::connection('mysql')->table('note3')->select('stockcode', 'note')->orderBy('stockcode', 'ASC')->get(); $getNote4 = DB::connection('mysql')->table('note4')->select('stockcode', 'note')->orderBy('stockcode', 'ASC')->get(); return view('posts.index')->with('title', $title)->with('query', $query)->with('getNote1', $getNote1)->with('getNote2', $getNote2)->with('getNote3', $getNote3)->with('getNote4', $getNote4);這是我的截圖 這是我想要的桌子
1 回答

繁花如伊
TA貢獻(xiàn)2012條經(jīng)驗(yàn) 獲得超12個(gè)贊
不要隱藏單元格,而是在其中放置一個(gè)空值。
<td><textarea rows="2" cols="10" name="note1" class="note1 align-middle" data-stockcode="{{ $stockcode }}" data-stockname="{{ $stockname }}">
@foreach($getNote1 as $note1)
@if($note1->stockcode == $stockcode)
{{ $note1->note }}
@endif
@endforeach
</textarea></td>
然后它會(huì)很好地對(duì)齊
- 1 回答
- 0 關(guān)注
- 273 瀏覽
添加回答
舉報(bào)
0/150
提交
取消