2016-04-03 114 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背景,但我可以從答案中得出它不會幫助我 –