note 10283 added to mysql_num_fields
| From: | bwark at stanford dot edu | Date: | Sun, 24 Dec 2000 07:56:35 +0000 |
| Subject: | note 10283 added to mysql_num_fields | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9048@lists.php.net to get a copy of this message | ||
If you just want the number of fields in a table, you can do something like this:
--
$db_id = mysql_connet();
$result = mysql_query("DESCRIBE [tableName], $db_id);
$numFields = mysql_num_rows($result);
--
Because "DESCRIBE" returns one row for each field in the table (at least in MySQL), this
will work.
http://www.php.net/manual/function.mysql-num-fields.php