note 18318 added to function.mysql-list-fields
| From: | joe1977 at tlen dot pl | Date: | Fri, 18 Jan 2002 11:00:55 +0000 |
| Subject: | note 18318 added to function.mysql-list-fields | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25020@lists.php.net to get a copy of this message | ||
I'm not sure, but I guess PHP doesn't give any function to return id_number of field_name
inside certain table. This could be usefull if you want to have field_id.
function mysql_get_field_id($table, $name)
{
$link = mysql_connect('localhost', 'root', '');
$fields = mysql_list_fields("mydatabse", $table, $link);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++)
{ if(mysql_field_name($fields, $i) == $name) echo $i; }
}
Regards, Danny.
--
http://www.php.net/manual/en/function.mysql-list-fields.php
http://master.php.net/manage/user-notes.php?action=edit+18318
http://master.php.net/manage/user-notes.php?action=delete+18318
http://master.php.net/manage/user-notes.php?action=reject+18318