custom Fields

Discussion in 'PHP' started by nomzz, Aug 11, 2009.

  1. #1
    Hi,


    what would be the better approach to make custom fields like that it can be created from admin so later on table shouldnt be altered

    Like if customer has already table but we need to include more fields so we make one custome field table where one field will be label and other column name but in that case both table has to be altered every time

    One way is to already make max fields which is not a scenario in our problem.

    Any one having some idea would be great help

    Thanks
     
    nomzz, Aug 11, 2009 IP
  2. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #2
    As I understood, adding a column is the problem? This is simply done with a SQL query.
    ALTER TABLE `table_name` ADD `column_name` TEXT;
    PHP:
     
    Sky AK47, Aug 11, 2009 IP
  3. nomzz

    nomzz Well-Known Member

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #3
    yes we dont want to alter table every time...but i think you havent understood the main problem

    What would be the structure to add custom fields which is best way? Like user can add them by ownself without changing the code and without altering the table every time.
     
    nomzz, Aug 11, 2009 IP
  4. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #4
    OH, in that way. That's a little bit harder, but create one column for the extra field and save the information like you want.
    For example: Myfield=Thevalue;Secondfield=Secondvalue;
     
    Sky AK47, Aug 12, 2009 IP
  5. nomzz

    nomzz Well-Known Member

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #5
    can you explain bit more?
     
    nomzz, Aug 12, 2009 IP