Find the number of columns in a table

前端 未结 19 2258
Happy的楠姐
Happy的楠姐 2020-11-27 11:13

It is possible to find the number of rows in a table:

select count(*) from tablename

Is it possible to find the number of columns in a tabl

19条回答
  •  一生所求
    2020-11-27 12:03

    It is possible to find the number of columns in a table just by using 3 simple lines of PHP code.

    $sql="SELECT * FROM table";
    $query=mysqli_query($connect_dude,$sql);    
    $num=mysqli_num_fields($query);
    

    $num would return the number of columns on a given table in this case.

    Hopefully,it would help others.

提交回复
热议问题