2016-10-03 8 views
0

私は自分のテーブルの最後の列の内容を太字にしようとしていますが、それらのキーの値を選択して大胆で、非常に新しいjqueryを適用する方法はわかりません。大文字の表の列をPHPから生成

<?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; ?> 
+0

スタイリングのコンテンツは、通常のロジックを介して行われていない、それがクライアントになりますまたはサーバー側ではなく、スタイルシートを使用して、cssファイル。 – arkascha

+0

私はキー "状態"を選択し、値を太字にすることはできないと思う、CSS。 –

+0

テーブルセルに適用できる ':last-child'のようなセレクタがあります。 – arkascha

答えて

1

ただ、CSSを使用します(それはあなたが「太字」で何を意味するかである場合)は、Webページ内の

#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>

関連する問題