Re: looping through fields in a table

From: Date: Tue, 30 May 2000 14:15:35 +0000
Subject: Re: looping through fields in a table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-641@lists.php.net to get a copy of this message
On Tue, May 30, 2000 at 03:57:52PM +0100, M.vanderMerwe@expro.shell.co.uk wrote: > I have a big table and need to output most of the fields. Is there a > way to loop through the fields getting the fieldnames and the values? > > Thanks > > > Thys > $sql = "SELECT * from table where foo='foo"; $result = mysql_query($sql,$sqllink); while($row = mysql_fetch_array($result)){ reset($row); echo "ROW $row[foo]<br>\n"; while(list($key, $value) = each($row)){ echo "$key = $value<br>\n"; } echo "<hr>"; } This should give you ROW A field1 = foo field2 = bar foo = A ------- ROW B .... etc -- -- Chris Moyer -- cmoyer@chekinc.com -- PHP Developer -- Chek.com

« previous php.general (#641) next »