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

    Join Date
    Feb 2000
    Location
    Milton, Ontario, Canada
    Posts
    4
    Rep Power
    0
    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
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    15
    Maybe something like...

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

    $query="CREATE table table_name(";
    (for $i=0; $i<$total; $i++)
    {
    if($i != ($total-1))
    $query.="$cols[$i] varchar(50),"
    else
    $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
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    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
    Location
    British Columbia
    Posts
    11
    Rep Power
    0
    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 12th, 2004, 11:04 PM
  2. Summing columns from multiple tables then sorting
    By PeMo in forum PHP Development
    Replies: 9
    Last Post: October 25th, 2003, 11:47 PM
  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, 01:31 AM
  4. How to loop all rows into two columns
    By mtringal in forum PHP Development
    Replies: 3
    Last Post: June 26th, 2003, 12:40 AM
  5. Adding values of dynamically generated rows
    By Sharapov in forum HTML Programming
    Replies: 0
    Last Post: March 24th, 2003, 08:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo