Function, increment, while

Hello

I have this code:

while (my while loop) {

            $number = mysql_num_rows($pics_query);
                $i = 1;
                if ($i < $number) {
                    echo $number;
                }
                $i++;

}

It’s a simple if else statement to check if a row is latest submission.

How can I put that script in the loop into a function?

For some reason the increment isnt working in a function.

Thanks

because in every iteration of your loop, you reset $i to 1.
incidentally, you’d do far better to do a single query. Use a date field in your table, ORDER BY on it, and LIMIT 1.