Re: Retrieve field names from a table

From: Date: Thu, 01 May 2003 00:05:04 +0000
Subject: Re: Retrieve field names from a table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145871@lists.php.net to get a copy of this message
Hi, Thursday, May 1, 2003, 4:39:09 AM, you wrote: AB> I am trying to display a table from a checkboxed form (one checkbox for each AB> field), so the user can check certain fields to select the columns he AB> wishes. AB> However, I can't see how to retrieve the field names dynamically. AB> Could anybody please tell me how to do it? AB> This is what I have tried to do so far, probably with some elementary AB> mistake: AB> echo("<tr>"); AB> $sql="DESCRIBE contacts"; AB> $result=mysql_query($sql); AB> while($row = mysql_fetch_array($result)): AB> $field = $row["field"]; AB> print("<td>$field</td>"); AB> endwhile; AB> echo("</tr>"); AB> Thanks AB> Alberto Have a look at this function mysql_listfields() -- regards, Tom

« previous php.general (#145871) next »