第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在多個(gè) foreach 循環(huán)表中添加 if else 語(yǔ)句

在多個(gè) foreach 循環(huán)表中添加 if else 語(yǔ)句

PHP
富國(guó)滬深 2021-09-05 17:52:33
我有一個(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ì)齊


查看完整回答
反對(duì) 回復(fù) 2021-09-05
  • 1 回答
  • 0 關(guān)注
  • 273 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)