php - Add row in one table for every nth entry in another table -


Actually, I have a system where users are rewarded for every 10 comments. Therefore, in DB, a table captures comments, and another reward was added for every 10th comment. For example, if a user adds 40 comments, they will have 4 rewards / 4 rows in Table 2.

It seems so simple for me, but I can not seem to know it. Thought that maybe a modulus operator can help there, but I need to add a new line to the table 2 every time, not to write each time, or to rewrite the rows every time.

Appreciate Help; I think this is right in front of me!

I think you have a model, the first table, or at least one function that inserts You can capture some more functionality in that function, and do something like this:

  $ current = count_your_current_coments (); If (FMOD ($ current, 10) == 0) {insert_into_second_Table (); }  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -