我在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>
错误:
解析错误:语法错误,意外的t_string,期望','或';'' in/webpage/composition/login/portal/portal.php in Line 174
是否有另一种方法可以输出最后一个<td>
,距离第三个<td>
大约30%?
您需要在回声上逃脱字符串。
"</td><td style="padding-left: 30%;">"
尝试
"</td><td style="padding-left: 30%;">"
我建议尝试以下
双Quote
"<td style='padding-left: 30%;'>"
或
逃脱报价
"<td style="padding-left: 30%;">"