PHP で作成されたテーブルを取得しようとしています。ここでは、フォームによって一連の列ヘッダーが設定され、テーブルにはそれらの列のみが表示されます。
したがって、テーブルには、入力された日付範囲に応じて、4 つの列または 6 つの列が含まれる可能性があります。
私はいくつかのことを試しましたが、私が望むものには何も近づきません。
ここにいくつかのコードがあります:
echo '<table>';
echo '<tr>';
echo '<th>Last Name</td>';
echo '<th>First Name</td>';
if($column_date1 != '') { echo '<th>' . $column_date1 . '</td>'; }
if($column_date2 != '') { echo '<th>' . $column_date2 . '</td>'; }
if($column_date3 != '') { echo '<th>' . $column_date3 . '</td>'; }
if($column_date4 != '') { echo '<th>' . $column_date4 . '</td>'; }
if($column_date5 != '') { echo '<th>' . $column_date5 . '</td>'; }
echo '</tr>';
// I will have a loop in here that searches records in a database.
$mysqliFunctionResult = $mysqliFunction->query($mysqliFunctionQuery);
while($line = $mysqliFunctionResult->fetch_assoc()) {
?><tr>
<td><?php echo $line['tabledata1']; ?></td>
<td><?php echo $line['tabledata2']; ?></td>
<td><?php echo $line['tabledata3']; ?></td>
<td><?php echo $line['tabledata4']; ?></td>
<td><?php echo $line['tabledata5']; ?></td>
</tr>
<?php } ?>
</table>