Re: retrieving field names in ascending order
| From: | Pablo M. Rivas | Date: | Thu, 08 Sep 2005 11:30:29 +0000 |
| Subject: | Re: retrieving field names in ascending order | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40225@lists.php.net to get a copy of this message | ||
Hello Hope:
On 9/8/05, hope <umeed921@yahoo.com> wrote:
> how can i retrieve field names from a table(e.g products_attributes)
> in ascending order???
> i need to display each of the fieldnames alongwith its datatype and length
> on the page.
I suppose you use Mysql:
$result=mysql_query("SHOW COLUMNS FROM table",$db);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$k[$row['Field']]=$row['Type'];
}
ksort($k);
while (list($key,$value)=each($k)) echo "$key $value<br>\n";
}
Pablo.
--
Pablo M. Rivas. http://www.pmrivas.com http://www.r3soft.com.ar
-----------------------------------------------------------