Fixing looping bug (fixed)

actually it's so simple, no need for temporary variabel and no need for complex for loops.
I deleted the second for loop and move all of the echo (except "<br>") inside the first loop and tadaaa. It Works!