We have the code so that when the Arduino detects a value of 1 on digitalpin2, millis() begins.
Which you didn't post, but is impossible. The value returned by millis() starts when the Arduino resets, and is not (supposed to be) ever reset.
When the Arduino detects a value of 0 on digitalpin2, we want it to divide 1/(difference in time) to calculate the frequency.
So, what is the problem?
We want this loop to be continuous and have the millis counter reset after after calculation. can anyone help us please?
What does "continuous" mean? You are either waiting for a change in the square wave or you are doing something while periodically looking for a change (possibly interrupt based). Which is it?
You shouldn't, and don't need to, reset millis(). You don't reset your watch 15 times a day, do you? Of course not. You learn early on how to use a watch to determine the interval between two events. You should be doing the same with the millis() value.