Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

how can i insert same data from form (php) to mysql multiple time.

For example input=1 that insert it only once.

When input=2 insert it twice (the exactly same input)

Thanks for your answer

What I have tried:

I tried to search the internet for the "for loop" but i dont find any working soloutions.
Posted
Updated 28-May-20 5:48am

The algorithm is pretty simple:
  • for ($i = 0; $i < input; $i++)
    • insert the data
 
Share this answer
 
Why would you insert the same data multiple times? Generally speaking, that is a bad DB design - you normally design databases so they only contain one copy of anything, and everything else relates to that original value, normally by means of a row ID as a foreign key.

Deliberately adding the same data goes very much counter to that, ignoring that you can't have two identical rows in a DB anyway as the engine prevents that - normally the row ID column will contain unique values.
 
Share this answer
 
Comments
phil.o 28-May-20 11:51am    
I wondered why, too. But, who knows... :)
Fynn Pfingsten 28-May-20 11:58am    
Hi, the plan is that the id is different.

My plan was it that i insert for example number=2 and than i want to print it in fpdf twice. but i dont know how to do it, can you help me?
OriginalGriff 28-May-20 12:16pm    
So add a "NumberOfCopies" column, insert the data once, and update the copies count as necessary. When you print it, print that many copies, and clear the counter.
Easier, quicker, better design.
Fynn Pfingsten 28-May-20 13:52pm    
Thanks! I will try It tomorrow and give you a short reply.
Fynn Pfingsten 28-May-20 14:06pm    
One question, is it possible to display it in the table? Or does print only work. Because in the end, i need one page with a table. and when the form enter for example: name=test and copiestodisplay=2, in the table should be the entry twice. Do you understand me?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900