SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting info out of describe

    ok what i want to do is list the tables in a database, which i can do
    but i want each to be a link that describes the table

    how would i go about using describe and getting the info out like when you query in the comand propt

  2. #2
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just like you would with any other data I suppose.

    This is a sample output of DESCRIBE (from MySQL's manual):

    Code:
    +------------+----------+------+-----+---------+----------------+
    | Field      | Type     | Null | Key | Default | Extra          |
    +------------+----------+------+-----+---------+----------------+
    | Id         | int(11)  | NO   | PRI | NULL    | auto_increment |
    | Name       | char(35) | NO   |     |         |                |
    | Country    | char(3)  | NO   | UNI |         |                |
    | District   | char(20) | YES  | MUL |         |                |
    | Population | int(11)  | NO   |     | 0       |                |
    +------------+----------+------+-----+---------+----------------+
    What specifically do you have a problem with?

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am sorry i meant how would you get this to echo, using the example in the first post

    would you use mysql_fetch_array or mysql_fetch_field ?
    (using this for database searching, nothing live)

  4. #4
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by craqgerbil View Post
    i am sorry i meant how would you get this to echo, using the example in the first post

    would you use mysql_fetch_array or mysql_fetch_field ?
    (using this for database searching, nothing live)
    Query the database "DESCRIBE tablename" and then

    Code:
    foreach ($row = mysql_fetch_array()) {
        // $row is an array with those keys: Field | Type | Null | Key | Default | Extra 
    }
    to get info about each column.

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you


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
  •