2016-10-03 3 views
0

Ich versuche, den Inhalt der letzten Spalte meiner Tabelle zu fett, nicht sicher, wie diese Schlüsselwerte auswählen und wenden Sie eine Fettdruck, sehr neu mit Jquery.Fett Tabellenspalte generiert von 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

Styling Inhalte in Web-Seiten (wenn das, was Sie unter "bold") wird in der Regel nicht über Logik erfolgen, sei es Client oder serverseitig, aber mittels Stylesheets, also CSS-Dateien. – arkascha

+0

Ich denke nicht, dass ich den Schlüssel "Status" auswählen und die Werte in css fett formatieren kann. –

+0

Es gibt Selektoren wie ': last-child', die Sie auf die Tabellenzellen anwenden können ... – arkascha

Antwort

1

Verwenden Sie einfach 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>