I have this script that generates an HTML table based on MySql table. I would like for it to hide the first column.
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<th id = 'tableheader'>{$field->name}</th>";
}
echo "</tr>
";
echo "<tr><td id = 'line'></td id = 'line'><td id = 'line' ></td><td id = 'line' ></td><td id = 'line' ></td><td id = 'line' ></td></tr>";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td id = 'tabledata'>$cell</td>";
echo "<td><form method='post' action='delete.php'><input type='hidden' name='id' value='{$row['0']}'/><input type='submit' value='Delete'/></form></td>";
echo "</tr>
";
}
You can do it with CSS:
th:first-child, td:first-child {
display: none;
}
Live demo: http://jsfiddle.net/Pzf9Y/2/
You may need to know about array_shift
Example
$array = array(
'one',
'two',
'three',
'four',
'five',
);
array_shift($array); // Remove the first element of array
foreach($array as $data){
echo 'I\'m number '.$data.'<br/>';
}
Output :