SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Table Column Names

    Is there a way to display a tables columns,
    and then filter out the column names?

    Code MySQL:

    But I'd like to somehow filter it with
    LIKE 'custom_%' -- or however that goes, so it only shows Column names that have custom_ as a prefix.

    Or should I do this in PHP?

    I'll go through my book again I don't recall seeing something like this off the top of my head.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SHOW COLUMNS FROM users LIKE 'custom_%'
    You can also do something like
    Code:
    SELECT COLUMN_NAME 
      FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'thedatabasename' 
       AND TABLE_NAME = 'users'
      AND (...other filtering clauses...)

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well that was easy lol, thanks a lot


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
  •