0
SELECT count(*) FROM information_schema.`COLUMNS` C
WHERE table_name = 'your_table_name'
AND TABLE_SCHEMA = "your_db_name"

TABLE_SCHEMA is required only if table name exists in more than one db

4
Contributors
3
Replies
24
Views
7 Years
Discussion Span
Last Post by Terry_2
0

Hi,

this should help

$myQuery = "show columns from $my_table_name";
$result = mysql_query($myQuery);
$row = mysql_fetch_row($result);
$columncount = count($row);

Edited by whiteyoh: n/a

0

it so simple:-
$result=mysql_query("select * from table_name");
echo mysql_num_field($result);

finish....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.