在html表

时间:2016-04-03 10:31:14

标签: php html

我已经编写了以下代码,用于将下载监视器输出转换为html表。

<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>

然而,这给了我如下所示的输出

enter image description here

如何修改代码,以便每次下载都不会重复表头。

更新:这是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传递给模板。模板代码是具有表格的代码,并具有重复的表头。我想要一个包含下载标题,类别和下载链接的三列表。

1 个答案:

答案 0 :(得分:0)

<th></th>代码替换为<td></td>并使用<strong>Content</strong>

<div class="table-1">
    <table width="100%">
        <thead>
        <tr>
            <td><strong>Lab Title</strong></td>
            <td>Download</td>
        </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>