SELECT * FROM table ORDER BY rand() LIMIT 1
$dir=glob("img/*"); echo '<img src="'.$dir[array_rand($dir)].'" />';