SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Editing a Table

  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Editing a Table

    Is it possible to insert another table-column into an exsisting table?

    Say my table looks like this:
    -table REPORTS (
    rID // ID of the reports
    eID // ID of the events the report is of (1-many)
    rText // Text of the REPORT
    rAuthor // Author of the REPORT
    )

    Now, I want to add another column (??) to this table:
    rOnline // a 'boolean' for a check if the Report is authorized to appear online. An editor has to check its contents before it may appear online.

    So, this would be fairly easy to do when you don't have anything in the table yet. Just create a new one.

    But, is it possible to ADD another row to the Table which has already many rows (content)?
    If so: How do I do this with PHP? (using MySQL)

    Please advise, any help is appreciated!

    Jazz

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest way to alter tables is to use phpMyAdmin:

    http://www.phpwizard.net/projects/phpMyAdmin/

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx...

    I can't use PHPAdmin on my server. But I saw how the PHPAdmin does this on another database.

    ALTER TABLE report ADD rOnline TINYINT (1)

    Thanx!

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought it was ADD COLUMN, but I guess that will work, too.

  5. #5
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by TWTCommish
    I thought it was ADD COLUMN, but I guess that will work, too.
    It is In this case, rOnline is the column name.

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No no, I meant this

    ALTER TABLE blah ADD COLUMN column_name TEXT NOT NULL;


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
  •