note 69128 deleted from function.mysql-query by googleguy

From: Date: Tue, 22 Oct 2013 14:59:05 +0000
Subject: note 69128 deleted from function.mysql-query by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197269@lists.php.net to get a copy of this message
Note Submitter: spencer at barekoncept dot com ---- Here's an easy way to store the column names from a specified table in the array "cnames". $result = mysql_query("SHOW COLUMNS FROM tablename"); $count = 0; while ($row=mysql_fetch_row($result)){ $cnt = 0; foreach ($row as $item){ if ($cnt == 0){ $cnames[$count] = $item; $cnt++; $count++; } } } Then, to display the results comma delimited: foreach($cnames as $c){ echo $c.","; } I hope this helps some people as it took me a while to figure it out.

« previous php.notes (#197269) next »