我有这个脚本,它根据MySql表生成一个HTML表。我想隐藏第一列。
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<th id = 'tableheader'>{$field->name}</th>";
}
echo "</tr>\n";
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>\n";
}
答案 0 :(得分:3)
答案 1 :(得分:2)
您可能需要了解array_shift
示例强>
$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/>';
}
输出: