You are here: RE: [PHP] db insert question « PHP « IT news, forums, messages
RE: [PHP] db insert question

Posted by Cafer Simsek on 07/21/05 17:13

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 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?
> > >>
> > >>
> > >>Thanks for any help.
> > >
> > >
> > > A generic question begs a generic answer:
> > >
> > > foreach($formdata as $thisdata){
> > > $result=mysql_query("insert into ... values($thisdata)
> > where ...");
> > > }
> > >
> > >
> > > Hope this helps, but it would be useful to have code
> > examples, etc so that a
> > > more relevant answer could be rendered.
> > >
> > > JM
> > >
> >
> > 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?
> >
>
> 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 PHP. Sorry I couldn't help.
>
> JM
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация