PHP newbie question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fireorange
    Confirmed User
    • Jan 2005
    • 1648

    #1

    PHP newbie question

    I'm searching for the code to batch import stuff into a MySQL db, can't find shit.

    Example:

    abc
    zyx
    qwe
    asd

    Each on a seperate line, from a HTML form submit.

    Any help?
  • ddfGandalf
    Confirmed User
    • Feb 2005
    • 534

    #2
    Dunno really what you need, but you could use $HTTP_POST_VARS or $HTTP_GET_VARS depending on your form action, then process the array (while) and simple INSERT into db?

    Comment

    • Serge Litehead
      Confirmed User
      • Dec 2002
      • 5190

      #3
      batch import: http://sunsite.mff.cuni.cz/MIRRORS/f...atch_mode.html

      the example is not clear in regards to mysql subject

      Comment

      • MickeyG
        Confirmed User
        • May 2004
        • 4134

        #4
        if its a html submit use a loop, otherwise you can use a txt file and then import into mysql.

        Comment

        • fireorange
          Confirmed User
          • Jan 2005
          • 1648

          #5
          Originally posted by MickeyG
          if its a html submit use a loop, otherwise you can use a txt file and then import into mysql.
          Yea that's what I want but I can't find any sample code on Google to use.

          Comment

          • psili
            Confirmed User
            • Apr 2003
            • 5526

            #6
            something like:

            Code:
            $txt_array = file('/path/to/file.txt');
            $db = ....connect to db
            
            for($i=0;$i<count($txt_array);$i++)
            {
              $sql = "insert into something where
            }
            
            ...
            FUCK THAT...

            Can't you just format your text file like how the table is formatted and run something like:

            >load data infile .....

            -- search good for "load data in file" -- that'd be the fastest and easiest if possible.
            Your post count means nothing.

            Comment

            Working...