You are missing a
) at the end of the
while line, and another on the
array_push line. If you are seeing no error, you probably have error reporting off. Using an editor with syntax highlighting would help you find this kind of error, as they usually include highlighting of mismatched parentheses.
Note that you could simplify your query a little by using
... and e.id_step IN (4,5,6)
... and e.id_step BETWEEN 4 AND 6