php help - creating default value for specific column on html table

Fugitive

New Member
I need some help tweaking this php code to print out a default value for a specific column. I'm printing out the following column header columns in a table:\[code\]Host Target Date Set Time Length Size Status\[/code\]There are instances in the 'tst.txt' input file where I don't have data for the last (3) columns \[code\]Length Size Status\[/code\]I originally was creating a blank cells for this data, but now I want to put a DEFAULT data for only the column: \[code\]Status\[/code\] where if status is null then print \[code\]CHECK FOR ERRORS\[/code\] as an example.I tried coding that below, but its doing it for every blank cell, but I just want it for column status. Thanks!\[code\]<?php$data = http://stackoverflow.com/questions/3631190/array();$InputFile = file("tst.txt");foreach ($InputFile as $line){ preg_match_all("/([0-9])-([^=]+)=([^;]+);/", $line, $matches, PREG_SET_ORDER); $LineData = http://stackoverflow.com/questions/3631190/array(); foreach ($matches as $information) { $LineData[$information[2]] = $information[3]; } $timestamp = strtotime($LineData["Date"]." ".$LineData["Time"]); $data[$timestamp] = $LineData;}ksort($data);$keys = array('Host', 'Target','Date','Set','Time', 'Length','Size','Status');echo '<table><tr>';foreach ($keys as $column) echo '<th>' . $column . '</th>'; echo '</tr>';foreach ($data as $row){ echo '<tr>'; foreach ($keys as $column) if (isset($row[$column])){ echo '<td>' . $row[$column]; } else { //echo '<td>' . '' . '</td>'; echo '<td>' . 'Check for Errors' . '</td>'; }}echo '</table>';//print_r($data);?>\[/code\]
 
Back
Top