从 php 生成的粗体 table 列
Bold table column generated from php
我正在尝试将 table 最后一栏的内容加粗,但不确定如何 select 这些键值并使用 jquery 应用非常新的粗体。
<?php
$items = array(
array("City" => "Dalas","Age" => "47", "Name" => "Janet Fuller", "Address" => "445 Upland Pl.", "Status" => "Trial"),
array("City" => "Lyon", "Age" => "38", "Name" => "Andrew Heiniger", "Address" => "347 College Av.", "Status" => "Active"),
array("City" => "Dallas", "Age" => "43", "Name" => "Susanne Smith", "Address" => "2 Upland Pl.", "Status" => "Active"),
array("City" => "Paris", "Age" => "25", "Name" => "Sylvia Steel", "Address" => "269 College Av.", "Status" => "Suspended"),
array("City" => "San Francisco", "Age" => "7", "Name" => "James Peterson", "Address" => "231 Upland Pl.", "Status" => "Active"),
array("City" => "Oslo", "Age" => "42", "Name" => "Robert Ott", "Address" => "503 Seventh Av.", "Status" => "Trial")
);
?>
<?php if (count($items) > 0): ?>
<table>
<thead>
<tr>
<th><?php echo implode('</th><th>', array_keys(current($items))); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $row): array_map('htmlentities', $row); ?>
<tr>
<td><?php echo implode('</td><td>', $row); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
只需使用css:
#myTable td:last-child {
font-weight: bold;
}
<table id="myTable">
<thead>
<tr>
<th>first</th>
<th>last</th>
</tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>last</td>
</tr>
</tbody>
</table>
我正在尝试将 table 最后一栏的内容加粗,但不确定如何 select 这些键值并使用 jquery 应用非常新的粗体。
<?php
$items = array(
array("City" => "Dalas","Age" => "47", "Name" => "Janet Fuller", "Address" => "445 Upland Pl.", "Status" => "Trial"),
array("City" => "Lyon", "Age" => "38", "Name" => "Andrew Heiniger", "Address" => "347 College Av.", "Status" => "Active"),
array("City" => "Dallas", "Age" => "43", "Name" => "Susanne Smith", "Address" => "2 Upland Pl.", "Status" => "Active"),
array("City" => "Paris", "Age" => "25", "Name" => "Sylvia Steel", "Address" => "269 College Av.", "Status" => "Suspended"),
array("City" => "San Francisco", "Age" => "7", "Name" => "James Peterson", "Address" => "231 Upland Pl.", "Status" => "Active"),
array("City" => "Oslo", "Age" => "42", "Name" => "Robert Ott", "Address" => "503 Seventh Av.", "Status" => "Trial")
);
?>
<?php if (count($items) > 0): ?>
<table>
<thead>
<tr>
<th><?php echo implode('</th><th>', array_keys(current($items))); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $row): array_map('htmlentities', $row); ?>
<tr>
<td><?php echo implode('</td><td>', $row); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
只需使用css:
#myTable td:last-child {
font-weight: bold;
}
<table id="myTable">
<thead>
<tr>
<th>first</th>
<th>last</th>
</tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>last</td>
</tr>
<tr>
<td>first</td>
<td>last</td>
</tr>
</tbody>
</table>