Mysqli选择列名但跳过第一列

时间:2015-09-04 07:47:22

标签: php mysql mysqli

我试图显示一个表名列表,该列表使用下面的代码,但我希望它跳过第一列(ID号)。如何实现这一目标?

$forms_colums = array();
$get_table_colums = mysqli_query($capital_db, "SHOW COLUMNS FROM tbl_customers ");
while ($found_table_colums = mysqli_fetch_array($get_table_colums)) {
    $forms_colums[] = $found_table_colums['Field'];
}

1 个答案:

答案 0 :(得分:2)

您可以在末尾添加array_shift($forms_columns),从而删除数组中的第一个元素:

$forms_colums = array();    
$get_table_colums = mysqli_query($capital_db,"SHOW COLUMNS FROM tbl_customers ");
while($found_table_colums = mysqli_fetch_array($get_table_colums))
{
    $forms_colums[] = $found_table_colums['Field'];     
}
array_shift($forms_colums);