我有一個(gè)具有唯一編號(hào)的 api,該編號(hào)不同,因此當(dāng)我使用該唯一編號(hào)調(diào)用 api 時(shí),我會(huì)返回?cái)?shù)據(jù),并在表中顯示數(shù)據(jù)。該表有一個(gè)列名稱“amount”。由于其動(dòng)態(tài)數(shù)據(jù)來自 API,我只是困惑如何在表格的最底部顯示總量。我正在使用 Laravel。我的代碼示例<table class="table table-one"> <thead class="table-success"> <tr> <th scope="col">Inst. No.</th> <th scope="col">PR No.</th> <th scope="col">PR Date</th> <th scope="col">Prem. Amt.</th> </tr> </thead><!-- ends: thead --> <tbody> @foreach ($results['polinfo'] as $data) @foreach ($data['poldata'] as $res) <tr> <th scope="row">{{$res['INSTALNO']}}</th> <td>{{$res['PR_NO']}}</td> <td>{{$res['PR_DATE']}}</td> <td>{{$res['AMOUNT']}}</td> </tr> @endforeach @endforeach </tbody><!-- ends: tbody --> </table>我必須計(jì)算所有 {{$res['AMOUNT']}} 并必須將其顯示為總金額。
從來自 api 的表列中獲取總金額的總和
哆啦的時(shí)光機(jī)
2023-07-08 21:42:35