Re: showing any mysql query in a table, help!
| From: | Curt Zirzow | Date: | Sun, 19 Mar 2006 18:51:21 +0000 |
| Subject: | Re: showing any mysql query in a table, help! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232217@lists.php.net to get a copy of this message | ||
On Sun, Mar 19, 2006 at 05:12:06AM +0000, pgaio@portugalmail.pt wrote:
> Ok...
> it has to be a way to do such a thing.
> I do i get the column names?
> I can get the number of columns using mysql_num_fields() right?
> but what if i want to get the columns name? Wich functtion and how should i use?
http://php.net/mysql_fetch_field
Something like:
$result = mysql_query($sql);
$j = mysql_num_fields($result);
for($i = 0; $i < $j; $j++ ) {
$field = mysql_fetch_field($result, $i);
echo $field->name;
}
Curt.
--
cat .signature: No such file or directory