SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: collum names

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    collum names

    I know this question was posted not long ago, and I kinda remember breifly reading it, but now that I actually need to know the awnser to the question, I cant seem the find the post

    The question is..
    How can I retrieve the names of the collums in a mysql database.
    kets say I have 4 collums
    id | name | address | email |

    is there a function to retrieve those values?

    thanx

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you are after?

    PHP Code:
    <?
    $db 
    mysql_connect("localhost""""") or DIE(mysql_error());
    $database "mysql";
    $table "user";
    $result mysql_list_fields($database$table);
    for(
    $i=0;$i<mysql_num_fields($result);$i++) {
        print 
    mysql_field_name($result$i)."<br>";
        }
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •