php - innerHTML PHP 内联 css 给出解析错误

标签 php html css

<分区>

我将我的数据库数据输出到 HTML 表格中。我希望最后一个向右输出更多。但是,如果我使用内联 css 样式,则会出现解析错误:

我的代码:

<table class="scroll">
    <thead style="background-color: #99E1D9; color: #705D56;">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Last Update</th>
            <th style="padding-left: 30%;">Status</th>
        </tr>
    </thead>
        <tbody id="hoverTable">
                <?php

                    $connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
                    mysql_select_db('patientdb');

                    $query = "SELECT id, name, date, status FROM clients"; //You don't need a ; like you do in SQL
                    $result = mysql_query($query);

                    while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
                    echo "<tr> 
                            <td>" . $row['id'] . "</td> 
                            <td>" . $row['name'] . "</td> 
                            <td>" . $row['date'] . "</td>

<td style="padding-left: 30%;">" . $row['status'] . "</td>

                         </tr>";  //$row['index'] the index here is a field name
                    }

                    mysql_close(); //Make sure to close out the database connection
                ?>
</tbody>
</table> 

错误:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /webpage/composition/login/portal/portal.php on line 174

还有其他方法可以输出最后一个<td>吗?与第三个相差约 30% <td> ?

最佳答案

你需要在回显中转义你的字符串。

"</td><td style="padding-left: 30%;">"

尝试

"</td><td style=\"padding-left: 30%;\">"

关于php - innerHTML PHP 内联 css 给出解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41253515/

上一篇:html - 如何在 css 中为每个 html 帖子设置不同的样式

下一篇:javascript - 如何向元素中的 id 添加附加属性?

相关文章:

php - mysqli::query() 在选择查询时返回 true

jquery - 这与其他选择器

jquery - 如何停止我的 jquery 动画?

php - 更新多维数组sql php

php - 尝试从 mysql 数据库检索用户个人资料图片。

html - 如何使修改后的单选按钮可制表?

javascript - 隐藏所有网站的div

html - 使用 AngularJS 更改 CSS 取决于文本框值

css - UL 或 DIV 垂直滚动条

php - 如何从服务器端 php 和 mysql 管理各种客户端应用程序(android/iphone)之间的 session token ?