Jump to content


Photo

Field Name and value


  • Please log in to reply
1 reply to this topic

#1 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 06 April 2006 - 01:40 AM

I have a table with about 40 fields What I want to do is loop thru the field names and values and print them to the screen edit them.

So i have a row with id#2, I want to return each field name and the value for that field name in a loop.

Ray


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 06 April 2006 - 11:53 PM

if you use

$row = mysql_fetch_assoc($result);

then $row is an array of field values whose key is the field name

foreach ($row as $fname => $value) {

        echo "$fname : $value<br>";

}

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users