我有一個下面的代碼,我已經寫入將下載監視器輸出轉換爲html表格。在html表格中輸出格式的php
<div class="table-1">
<table width="100%">
<thead>
<tr>
<th>Lab Title</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php $dlm_download->the_title(); ?></td>
<td><a href="<?php $dlm_download->get_the_download_link(); ?>">
<?php $dlm_download->the_title(); ?> (<?php echo $dlm_download->get_the_download_count(); ?>)</a></td>
</tr>
</tbody>
</table>
</div>
然而,這給我的輸出如下圖所示
我怎麼可以修改代碼,以便表頭不重複,每下載。
更新:這裏的PHP代碼
<?php global $dlm_page_addon; ?>
<div class="download_category download_group">
<!-- <h3><a href="<?php // echo $dlm_page_addon->get_category_link($category); ?>"><?php //echo $category->name; ?> <?php //if ($category->count) : ?>(<?php //echo $category->count; ?>)<?php //endif; ?></a></h3> -->
<?php while ($downloads->have_posts()) : $downloads->the_post(); ?>
<?php $dlm_download = new DLM_Download(get_the_ID()); ?>
<?php $template_handler = new DLM_Template_Handler(); $template_handler->get_template_part('content-download', $format, $dlm_page_addon->plugin_path() . 'templates/', array('dlm_download' => $dlm_download)); ?>
<?php endwhile; ?>
</div>
據我瞭解,這個代碼將數組$ dlm_download到模板。模板代碼是包含表格並具有重複表格標題的模板代碼。我想有一個三列表下載標題,類別和下載鏈接。
你是否也有解決此代碼的任何'php'循環代碼? –
您沒有顯示任何PHP代碼,所以無法說出任何內容。但是Anant的假設很可能是正確的:你每次循環輸出所有這些。只將需要重複的部分放入循環中。 –
添加了循環代碼。 –