It is been a while on this thread but I am looking for the same functionality , the php code did not work ,
$max=10;//quantity of images
$fp=fopen ("img.txt", "r");
$n=fread ($fp)+1;
if ($n>$max)
$n=1;
fclose ($fp);
$fp=fopen ("img.txt", "w");
fwrite ($fp, $n);
fclose ($fp);
print '<img src="pic'.$n.'.gif" />';
what does img.txt contain , I am getting the following error "Warning: Wrong parameter count for fread() "