Have you actually ran this script? It looks like you would access it from a POST operation from a web form. I really don't know much about the GD toolkit, but I do not see any image being passed into it, just the height and width parameters. The only odd thing I'm seeing is this line"
$c_row = explode(",", $_POST['px' . $rows]);
Which looks like an image is somehow being extracted row by row(and later in the code, column by column), but I see no image handler for it specifically. For all I can tell, it's writing a png of a single color.
As for your original question, you are going to need to create a semipermanent placemarker, either within a database or within a file you can read from/write to, so you know where you left off. So, you are looking at either needing database code or file handling code.
after you access your placemarker, you are going to do an increment of the counter portion of it. So, if your counter is 23, you'll need to increment it to 24. A common way of doing it is to take the variable placeholder and follow it with two pluses. an example is below:
$counter=$counter++;
You will then need to concatenate the counter onto the standard placeholder name, followed by the extension. You do concatenation using a period. Here is an example:
$filename="Picture";
$counter="23";
$extension=".png";
$full_filename=$filename . $counter . $extension;
In the above example, you would end up with a full filename of "Picture23.png".
This is some starting points for you. Take a look at what I've written and see what you can do with it. When you get stuck, come back with more questions.