Exemple #1
0
 public static function viewCarDetails($car)
 {
     foreach ($car as $attribute => $value) {
         $clean = HTML::cleanAttribute($attribute);
         echo '<b>' . $clean . '</b>: ' . $value . '<br />';
     }
 }
Exemple #2
0
 public static function generateTable($array)
 {
     if (is_array($array)) {
         $i = 0;
         $find = 'id';
         // ID should be generated as links
         $htmlTABLE = '<table><tr>';
         // Get table headings
         foreach ($array as $key => $innerArray) {
             if (is_array($innerArray)) {
                 foreach ($innerArray as $attribute => $value) {
                     if (strpos($attribute, $find) !== false) {
                         $htmlTABLE .= '<th>Action</th>';
                     } else {
                         $clean = HTML::cleanAttribute($attribute);
                         $htmlTABLE .= '<th>' . $clean . '</th>';
                     }
                 }
                 if (++$i == 1) {
                     break;
                 }
             }
         }
         $htmlTABLE .= '</tr>';
         // Get the rest of the table
         foreach ($array as $key => $innerArray) {
             if (is_array($innerArray)) {
                 $htmlTABLE .= '<tr>';
                 foreach ($innerArray as $attribute => $value) {
                     if (strpos($attribute, $find) !== false) {
                         $href = 'index.php?page=car&id=' . $value;
                         $htmlTABLE .= '<td>' . Link::newLink('View', $href, '_self') . '</td>';
                     } else {
                         $htmlTABLE .= '<td>' . $value . '</td>';
                     }
                 }
                 $htmlTABLE .= '</tr>';
             }
         }
         $htmlTABLE .= '</table>';
         return $htmlTABLE;
     }
 }