TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   How to Insert Multiple Rows At Once in PHP (http://forums.techarena.in/software-development/1249727.htm)

Zeverto 22-09-2009 02:30 PM

How to Insert Multiple Rows At Once in PHP
 
I have tried inserting multiple rows in database with the help of PHP I am using MySQL as my database but it give me an continues error list I have tried restarting my application, as it might kept any thing wrong in its cache but does not work out I have used simple inserting statment such as $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d','$e')"; I am sure that there is absolutely no problem, but it does not working out. please help.

pancham 22-09-2009 03:23 PM

Re: How to Insert Multiple Rows At Once in PHP
 
If you want to insert multiple rows at once the standard procedure is to first select multiple rows and then use the "Insert" command. When it comes to inserting data the GridView has very little to offer. Using a technique as illustrated in my article titled Inserting a New Row in GridView you can insert a single record using EmptyDataTemplate of the GridView. However, what if you want to insert multiple rows using GridView?

Alchmey 22-09-2009 03:28 PM

Re: How to Insert Multiple Rows At Once in PHP
 
Try creating a function with a new recordset and call that function only when adding to the database, In real world cases developers often require such a mechanism. Orelse you may insert into t1 values(,,,) insert into t2 values(,,,) insert into t3 values(,,,,)......try this ........

Mecurtis 22-09-2009 03:30 PM

Re: How to Insert Multiple Rows At Once in PHP
 
By design the GridView control is a data bound control. That means it always requires some data source to bind with. One more thing, does access treat this huge statement as a transaction ie. take it or leave it or does it execute until it encounters an error or until it finishes? It cannot be used in unbound fashion. In order to display empty rows in the GridView you need to have a data source that contains empty items.


All times are GMT +5.5. The time now is 08:30 AM.