-1

I m designing a website in which I want to add multiple rows into database on single click. I want to add the results of the students of whole class in the students database which contains columns "s_id, subject_name, subject_result". I have design a simple form which list all the students and a text box in which result is to be added and on the submit button the results to be updated on the students database.

plzz give me some suggestions or link

vishal5721
  • 43
  • 5
  • 2
    duplicate of http://stackoverflow.com/questions/779986/insert-multiple-rows-via-a-php-array-into-mysql -- please use the search before you ask a new question. – Felix Kling Mar 11 '12 at 13:36

3 Answers3

1

There's a very good example on how to achieve this using PHP's implode statement right here in this very site. Mind you, I'm not sure what DB you're using but I'm going under the assumption that you're using a *AMP stack.

Community
  • 1
  • 1
Carlos
  • 1,897
  • 3
  • 19
  • 37
0
INSERT INTO results (`s_id`, `subject_name`, `subject_result`) 
VALUES (1, 'a1', 's1'), (2, 'a2', 's2'), ...;
Kaii
  • 20,122
  • 3
  • 38
  • 60
user1236048
  • 5,542
  • 7
  • 50
  • 87
0

If they are submitting the information via a form then the variables should be in an array. You can just loop through the array inserting into the database upon each loop.

I know it's not multiple multiple rows being inserted at once, but it is very fast and works. I've used this method to insert thousands of records at a time with this.

Hope it helps.

Take care, Shannon

Shannon Cole
  • 362
  • 7
  • 21