我有一个下面的代码,我已经写入将下载监视器输出转换为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的假设很可能是正确的:你每次循环输出所有这些。只将需要重复的部分放入循环中。 –
添加了循环代码。 –