codice:
<style type="text/css">
.c<?php echo substr($row['foto'], 0, -4); ?>{
width: 40px;
background-image: url(images_photogallery/<?=$row['foto']?> );
background-repeat: no-repeat;
background-position: center;
}
</style>
non penso proprio che una cosa scritta così abbia senso.
.c cos'è?

nel css scrivi codice php?