Fnord.
Well, one obvious point is that it's difficult to get something out of the table if it's not in there to begin with ...
Here's something you can do:
Get a list of all the unique filenames in the table.
$result = mysql_query('SELECT DISTINCT html FROM temp2');
Read through the result list, and put all of them into an array $files_in_table.
while(list($files_in_table[]) = mysql_fetch_row($result))
{/*empty loop!*/}
(Just too elegant for my own good ... can't help it: it was originally
while($row = mysql_fetch_array($result))
{ $files_in_table=$row['html'];
}
[Edit: Indeed - way too elegant. I usually use a for() statement to loop through recordsets, so I didn't notice a bug that comes of using while(). Use the "expanded" version.)
You don't want any of the files in that list.
Now use that same directory-reading loop you've got now to build up a similar array listing all the files in the directory - $files_in_directory. You'll be wanting some of the files in that list.
So now you've got $files_in_table - an array of all the files listed in your table, and $files_in_directory, an array of the (interesting) files you've got in your directory. You want an array of all the files in the directory, except those that are in the table. PHP gives you a function for that:
$wanted_files = array_difference($files_in_directory, $files_in_table);