Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    INserting into MySQL from an array

    Hi

    Is there a way of inserting rows into MySQL from a PHP array. I know that I can do this:

    foreach ( $array as $val )
    {
    run an insert query for $val
    }

    however that creates many queries. Is there are smarter way ie performing only one insert query for all values of the array?

    Thanks, in advance

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Bulgaria
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I think the answer is NO
    However You can build a single string containing all the subsequent INSERT's delimited with ; and then execute a single mysql_query()...

    Alex

  • #3
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I took your advice and created a comma delimited string instead - thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •