[PHP] db insert question

2005-07-21 Thread JamesBenson
Im using mysql with PHP4, whats the best way to insert as many as 20 records at one time from a form? Currently im just assigning each one a variable but that is messy and takes ages, is their a way to loop over the array of form data then maybe do the same to enter it into a database?

RE: [PHP] db insert question

2005-07-21 Thread Jim Moseby
Im using mysql with PHP4, whats the best way to insert as many as 20 records at one time from a form? Currently im just assigning each one a variable but that is messy and takes ages, is their a way to loop over the array of form data then maybe do the same to enter it into a database?

Re: [PHP] db insert question

2005-07-21 Thread JamesBenson
Thanks for your reply, your example demonstrates what i was doing but does that do a MySQL query for every piece of data? So 20 form values would be 20 db queries, would that not consume a lot of resources? Is their another way? Thanks, James Jim Moseby wrote: Im using mysql with PHP4,

RE: [PHP] db insert question

2005-07-21 Thread Jim Moseby
Jim Moseby wrote: Im using mysql with PHP4, whats the best way to insert as many as 20 records at one time from a form? Currently im just assigning each one a variable but that is messy and takes ages, is their a way to loop over the array of form data then maybe do the same to

Re: [PHP] db insert question

2005-07-21 Thread Duncan Hill
On Thursday 21 July 2005 15:02, Jim Moseby typed: As far as I know, there is no way to insert 20 unique rows of data into a MySQL table without executing 20 queries.  Maybe someone else here does(?). Perhaps drop a note over on the MySQL list, since this is really more an SQL question than

RE: [PHP] db insert question

2005-07-21 Thread Cafer Simsek
Hi You may try sending multiple query with one mysql_query() function call via seperating by ;. Regards. -Cafer Prş, 2005-07-21 tarihinde 10:02 -0400 saatinde, Jim Moseby yazdı: Jim Moseby wrote: Im using mysql with PHP4, whats the best way to insert as many as 20 records at one

RE: [PHP] db insert question

2005-07-21 Thread Jim Moseby
On Thursday 21 July 2005 15:02, Jim Moseby typed: As far as I know, there is no way to insert 20 unique rows of data into a MySQL table without executing 20 queries.  Maybe someone else here does(?). Perhaps drop a note over on the MySQL list, since this is really more an SQL

Re: [PHP] db insert question

2005-07-21 Thread Matthew Weier O'Phinney
* JamesBenson [EMAIL PROTECTED] : Thanks for your reply, your example demonstrates what i was doing but does that do a MySQL query for every piece of data? So 20 form values would be 20 db queries, would that not consume a lot of resources? Not necessarily. If you use a prepared statement

Re: [PHP] db insert question

2005-07-21 Thread Duncan Hill
On Thursday 21 July 2005 15:23, Jim Moseby typed: Yes, MySQL supports an extended insert syntax of insert into foo (...) values (...), (...), (...). Interesting! Consulting the manual, I see that you are correct. So the OP would do something like: $sql=insert into foo values ;

Re: [PHP] db insert question

2005-07-21 Thread James Benson
Thanks for all your help, ive got it working as i needed, my db query is built like this, works but probably not the best way of doing it:- $sqlStart = INSERT INTO `tester` (; $sqlMiddle = ) VALUES (; $sqlEnd = ); $keys = array(); $values = array(); foreach($formData as

Re: [PHP] db insert question

2005-07-21 Thread Richard Lynch
On Thu, July 21, 2005 6:52 am, JamesBenson said: Thanks for your reply, your example demonstrates what i was doing but does that do a MySQL query for every piece of data? So 20 form values would be 20 db queries, would that not consume a lot of resources? Is their another way? Test it on