表中的数据没有显示我想要的方式

时间:2011-11-22 17:34:23

标签: php html-table

我有一个微调器,所发生的是旋转器中的任何数字,当提交表单时,它应该显示单词“quest”与旋转器中的数字一样多次。例如,如果旋转器中的数字是3,然后它将在表格中显示“任务”3次。

问题是在表格中显示。

目前使用我当前的代码,它显示如下:

quest
quest
quest

Question Id, Option Type, Duration .... These are table headings

它在表格外显示单词任务

相反,我想在“问题ID”列中显示“任务”一词,如下所示:

Question Id, Option Type, Duration...

quest
quest
quest

如何让它像上面的例子一样显示它?

Below is code

 <table border=1 id="qandatbl" align="center">
    <tr>
    <th class="col1">Question No</th>
    <th class="col2">Option Type</th>
    <th class="col1">Duration</th>
    <th class="col2">Weight(%)</th>
    <th class="col1">Answer</th>
    <th class="col2">Video</th>
    <th class="col1">Audio</th>
    <th class="col2">Image</th>
    </tr>
    <?php
    $spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
   for($i = 1; $i <= $spinnerCount; $i++) {
     echo "<tr>quest";
   }
}
?>
    <td class='qid'></td>
    <td class="options"></td>
    <td class="duration"></td>
    <td class="weight"></td>
    <td class="answer"></td>
    <td class="video"></td>
    <td class="audio"></td>
    <td class="image"></td>
    </tr>
    </table>

我确实尝试过echo "<td class='qid'></td>";,但这完全失败了

2 个答案:

答案 0 :(得分:1)

试试这个:

<table border=1 id="qandatbl" align="center">
<tr>
  <th class="col1">Question No</th>
  <th class="col2">Option Type</th>
  <th class="col1">Duration</th>
  <th class="col2">Weight(%)</th>
  <th class="col1">Answer</th>
  <th class="col2">Video</th>
  <th class="col1">Audio</th>
  <th class="col2">Image</th>
</tr>
<?php
 $spinnerCount = $_POST['txtQuestion'];
  if($spinnerCount > 0) {
   for($i = 1; $i <= $spinnerCount; $i++) {
?>

  <tr>
   <td class='qid'><?php echo $quest; ?></td>
   <td class="options"></td>
   <td class="duration"></td>
   <td class="weight"></td>
   <td class="answer"></td>
   <td class="video"></td>
   <td class="audio"></td>
   <td class="image"></td>
</tr>
<?php
 } // For
} // If
?>
</table>

答案 1 :(得分:0)

这是你想做的吗?在第一列中显示“任务”?

<table border=1 id="qandatbl" align="center">


   <tr>
    <th class="col1">Question No</th>
    <th class="col2">Option Type</th>
    <th class="col1">Duration</th>
    <th class="col2">Weight(%)</th>
    <th class="col1">Answer</th>
    <th class="col2">Video</th>
    <th class="col1">Audio</th>
    <th class="col2">Image</th>
    </tr>
    <?php
    $spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
   for($i = 1; $i <= $spinnerCount; $i++) { ?>
     <tr>

    <td class='qid'>quest</td>
    <td class="options"></td>
    <td class="duration"></td>
    <td class="weight"></td>
    <td class="answer"></td>
    <td class="video"></td>
    <td class="audio"></td>
    <td class="image"></td>
    </tr>

<?php
}
}
?></table>

&GT;