0
我正在製作一個函數,其中我試圖獲取的數據來自two columns
的one row
,並且生成了多行。數據安排在表格中,我試圖用three columns
而不是two
來製作表格,但它沒有解決。有時在某些行中,它會跳過一列,有時會在一行中輸出完美的3列。下面的代碼適用於每行中的two columns
。但是如何使數據在一行中出現在three column
?從後端獲取數據到一行中的三列
$r = 1;
$html = "";
$html .= '<table class="table table-bordered">
<tbody><tr>';
foreach($products as $pr) {
if($r != 1) {$rw = (bool)($r & 1);
$html .= $rw ? '</tr><tr>' : ''; }
$html .= '<td><strong>'.$pr->name.'</strong><br>'.'<strong>Rs '.$pr->price.'</strong><br>'.$this->product_barcode($pr->code, 30, 147).'</td>';
$r++;
}
$html .= '</tr></tbody>
</table>';
$data['html'] = $html;
這裏是輸出截圖。它在一行中排成兩列。我想要一列3列。
很抱歉,但所有這些值(名稱,價格,條形碼)的將是一個會有3一行又會有很多行。我能夠在排隊中解決2但不是3 – user1001176
對不起 - 我發現很難明確你的意思。你能否提供你的$ products數組的var_dump? –
1分鐘我會上傳屏幕截圖 – user1001176