1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Milton, Ontario, Canada
    Rep Power
    I am creating a program for a company to allow them to edit the database through their website. The only difficulty I have run into is the editing of a tables' dimensions. I need to know how to add rows and columns or just create a table while running through a loop in PHP. Any help would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Annapolis, Maryland US
    Rep Power
    Maybe something like...

    // put all column names in an array
    $cols=array("name", "age", "height");

    $query="CREATE table table_name(";
    (for $i=0; $i<$total; $i++)
    if($i != ($total-1))
    $query.="$cols[$i] varchar(50),"
    $query.="$cols[$i] varchar(50)); // no comma and end parentheses

    I dunno...give it a shot

  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    You add "rows" using INSERT.

    You can add "columns" using ALTER TABLE
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    British Columbia
    Rep Power
    You give them a form that allows them to choose what they want to see, your program converts that to a query and displays the results. If you let them mess with the structure, you're almost certainly in for headaches.
    Also, adding to existing rows uses UPDATE.

Similar Threads

  1. Replies: 3
    Last Post: February 13th, 2004, 12:04 AM
  2. Summing columns from multiple tables then sorting
    By PeMo in forum PHP Development
    Replies: 9
    Last Post: October 26th, 2003, 12:47 AM
  3. 5 table join returning too many rows of duplicate data
    By DC Dalton in forum PostgreSQL Help
    Replies: 13
    Last Post: August 14th, 2003, 02:31 AM
  4. How to loop all rows into two columns
    By mtringal in forum PHP Development
    Replies: 3
    Last Post: June 26th, 2003, 01:40 AM
  5. Adding values of dynamically generated rows
    By Sharapov in forum HTML Programming
    Replies: 0
    Last Post: March 24th, 2003, 09:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo