I have written a script which depending on the variable uploads $num files.
The value of $num is stored in a mysql column and each file is uploaded in an array $file[], then placed in a directory by the name $id_$i.jpg (for example).

The problem arises when I want to display the files back in a table. The $num is read back through the mysql query and if the amount of files is less than $num then I have a partially filled table. The cells with no filename display the icon which references "no image" as there is no file in the upload directory to reference.

What I would like to know is

1)if when the form is submitted and only half of the files are uploaded could I set the array so it realises that only half of $file[] has been filled, or that only 6 of 12 files have been uploaded.

2) Alternately, could I count the number of files in a directory on my server and store that value as an variable to set the number of columns in my table?

What would be the code for this???

Thanks in advance.