想要增加表php中特定列的宽度

时间:2016-06-29 07:39:30

标签: php

以下是学生ID,学生姓名和问题1等栏目。我想增加width of column "question"。我怎样才能做到这一点?

我尝试通过在表标题tag like width="100"中添加对象来添加宽度,它可以作为简单的html代码工作,但在我所需的代码中不起作用。 `

<?php
                    if (isset($result_display)) {
                        echo "<p><u>Result</u></p>";
                        if ($result_display == 'No record found !') {
                            echo $result_display;
                        } else {
                            echo "<table class='result_table'>";
                            echo '<tr><th>Student ID</th><th>Student Name</th><th>Question#1</th><th>Answer#1</th><th>Question#2</th><th>Answer#2</th><th>Question#3</th><th>Answer#3</th><th>Question#4</th><th>Answer#4</th><th>Question#5</th><th>Answer#5</th><th>Question#6</th><th>Answer#6</th><th>Question#7</th><th>Answer#7</th><th>Question#8</th><th>Answer#8</th><th>Question#9</th><th>Answer#9</th><th>Question#10</th><th>Answer#10</th><th>Question#11</th><th>Answer#11</th><th>Question#12</th><th>Answer#12</th><th>Question#13</th><th>Answer#13</th><th>Question#14</th><th>Answer#14</th><th>Question#15</th><th>Answer#15</th><tr/>';
                            foreach ($result_display as $value) {
                                echo '<tr>' . '<td class="e_id">' . $value->id . '</td>' .'<td class="name">' . $value->Student_name . '</td>' . '<td>' . $value->question1 . '</td>' . '<td class="j_date">' . $value->Answer1 . '</td>' . '<td>' . $value->question2 . '</td>' . '<td class="mob">' . $value->Answer2 . '</td>' . '<td >' . $value->question3 . '</td>' . '<td>' . $value->Answer3 . '</td>' . '<td>' . $value->question4 . '</td>' . '<td>' . $value->Answer4 . '</td>' . '<td>' . $value->question5 . '</td>' . '<td>' . $value->Answer5 . '</td>' . '<td>' . $value->question6 . '</td>' . '<td>' . $value->Answer6 . '</td>' . '<td>' . $value->question7 . '</td>' . '<td>' . $value->Answer7 . '</td>' . '<td>' . $value->question8 . '</td>' . '<td>' . $value->Answer8 . '</td>' . '<td>' . $value->question9 . '</td>' . '<td>' . $value->Answer9 . '</td>' . '<td>' . $value->question10 . '</td>' . '<td>' . $value->Answer10 . '</td>' . '<td>' . $value->question11 . '</td>' . '<td>' . $value->Answer11 . '</td>' . '<td>' . $value->question12 . '</td>' . '<td>' . $value->Answer12 . '</td>' . '<td>' . $value->question13 . '</td>' . '<td>' . $value->Answer13 . '</td>' . '<td>' . $value->question14 . '</td>' . '<td>' . $value->Answer14 . '</td>' . '<td>' . $value->question15 . '</td>' . '<td>' . $value->Answer15 . '</td>' .   '<tr/>';
                            }
                            echo '</table>';
                        }
                    }
                    ?>

                </div>
            </div>

1 个答案:

答案 0 :(得分:0)

在th标签中使用style属性,例如

<th style="width: 100px;">Question#1</th>

这应该可以胜任,否则你也可以使用%例如。

<th style="width: 30%;">Question#1</th>