2016-04-03 111 views
1

我有一个下面的代码,我已经写入将下载监视器输出转换为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> 

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

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

你是否也有解决此代码的任何'php'循环代码? –

+0

您没有显示任何PHP代码,所以无法说出任何内容。但是Anant的假设很可能是正确的:你每次循环输出所有这些。只将需要重复的部分放入循环中。 –

+0

添加了循环代码。 –

回答

0

<td></td>更换<th></th>标签和使用<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> 
+1

为什么人们会用'th'和'td'打破语义格式?他们的存在是有原因的。这与这个问题无关。 –

+0

你是对的@SamiKuhmonen。这不是问题的答案 –

+0

我不是来自PHP背景,但我可以从答案中得出它不会帮助我 –