<分区>
<分区>
我将我的数据库数据输出到 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/