+ Reply to Thread
Results 1 to 5 of 5

 

Thread: PHP Question - simply but cant find the answer

  1. #1
    frostie
    Guest



    OK, finally I have completed all my php pages, and completed the design of mySQL database

    So far, chuffed to bits with what I have managed to teach myself in under 1 week <img src=http://www.gamers-forums.com/smilies/contrib/ruinkai/biggthumpup.gif ALT=":thumb">

    Now the final hurdle...... I want to insert all my data into the table and I know it goes like;

    INSERT tablename (colname1, colname2, colname3)
    VALUES ('val1', 'val2', 'val3')

    But that is only for 1 row, if I wanted to add another to exactly the same table, how do I add new values, or do I have to add the INSERT line again?

    Ta

  2. #2
    ShowYouLoveThem
    Guest

    If you have space on your server, I'd install phpMyAdmin as it makes managing MySql database so much easier.

    Multiple inserts is one way; if you are just putting data in by hand, this is probably easiest as it is easier to fix if it goes wrong (i.e. you miss out a ').

    If you have a text/csv file you want to import have a look at :- www.mysql.com/doc/en/LOAD_DATA.html, I haven't used that method, but its the why phpMyAdmin does it in the background.

    php???? programs seem to be good - even though they are separate projects. I use phpMySql, phpAdsNew (For managing adverts, as seen at the top of the page) and phpBB2 (a php/MySql based forum).

    Nice to have another php hacker amongst us!

  3. #3
    frostie
    Guest

    SYLT thanks for that, I will be taking a look at the other options later, but how do you do the insert command with more than 1 set of values (ie, to create 3 rows)?

    Is it possible?

  4. #4
    ShowYouLoveThem
    Guest

    I haven't tried it, but from just scanning the manual it looks like
    Code:
     INSERT tablename (colname1, colname2, colname3)
    VALUES ('val1a', 'val2a', 'val3a'), ('val1b', 'val2b', 'val3b'), ('val1c', 'val2c', 'val3c')
    will work if you have MySql version 3.22.5 or later. Just repeat ('val1', 'val2', 'val3') for as many rows as you want.

    If this doesn't work (i.e you have an earlier version), then use multiple inserts.

    www.mysql.com/doc/en/INSERT.html

  5. #5
    frostie
    Guest

    THANK YOU !!! <img src=http://www.gamers-forums.com/smilies/contrib/ruinkai/biggthumpup.gif ALT=":thumb">

    It worked a treat :rollin:

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP redirect question
    By drivetowin in forum Programming
    Replies: 1
    Last Post: 31-12-04, 04:44 PM
  2. Shopping Channel / PHP Question.
    By draytop in forum Affiliate Window & buy.at
    Replies: 0
    Last Post: 09-08-04, 04:05 PM
  3. PHP question......again :)
    By uklejon in forum Programming
    Replies: 6
    Last Post: 11-05-04, 05:07 PM
  4. PHP and MySQL - Find and Replace - Update
    By Barry in forum Programming
    Replies: 2
    Last Post: 26-04-04, 04:16 PM
  5. Question about @ prefix in php
    By darrenw in forum Programming
    Replies: 2
    Last Post: 28-03-04, 05:40 PM

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
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2