Home > Archive > PHP Language > December 2006 > return db column names
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
return db column names
|
|
| toodi4 2006-12-01, 6:57 pm |
| This is probably a real simple question, but I cannot seem to find the
answer anywhere.
I am working on a php project that involves both mysql and mssql. When
working remotely, I do not have access to the db servers. I can call
them through php, but not directly from my remote pc. Sometimes I need
to know certain column names in a table because they've changed or I
don't have the information. Is there a way to simply call the column
names through php? I'm sure there must be since phpmyadmin does it,
but I can't figure out what it is.
| |
| Christian Wagner 2006-12-01, 6:57 pm |
| Try mysql_field_name or mssql_field_name
| |
|
| "toodi4" <toodi4@hotmail.com> wrote in message
news:1165002686.940003.121620@16g2000cwy.googlegroups.com...
> This is probably a real simple question, but I cannot seem to find the
> answer anywhere.
>
> I am working on a php project that involves both mysql and mssql. When
> working remotely, I do not have access to the db servers. I can call
> them through php, but not directly from my remote pc. Sometimes I need
> to know certain column names in a table because they've changed or I
> don't have the information. Is there a way to simply call the column
> names through php? I'm sure there must be since phpmyadmin does it,
> but I can't figure out what it is.
"Christian Wagner" <biderius@web.de> wrote in message
news:ekq2as$apm$03$1@news.t-online.com...
> Try mysql_field_name or mssql_field_name
Specifically the code I use is:
mysql_connect('localhost', '', '');
mysql_select_db('test'); // if needed
$query = 'SELECT * FROM tableName ORDER BY someUniqueID';
$result = mysql_query($query);
$i = 0;
while(@mysql_field_name($result, $i)) // suppress the last call
{
print mysql_field_name($result, $i) . '<br />' . "\n";
$i++;
}
-Lost
|
|
|
|
|