<?php echo '<p>Toutes les annonces</p><br>'; echo '<div class="">'; $prev_anounce = NULL; foreach($anouncement as $anounce) { if($anounce->id != $prev_anounce) { if(!is_null($prev_anounce)) { echo '</div>'; } } echo '<div class="miniature" style="background-image:url('pictures/'.$anounce['filename_product'].'); echo '<img src="'.htmlspecialchars($anounce->filename_product).'">'; echo '</div>'; if($anounce->id != $prev_anounce) { echo htmlspecialchars($anounce->titre).'<br>'; echo htmlspecialchars($anounce->presentation).'<br>'; echo htmlspecialchars($anounce->prix).'<br>'; echo htmlspecialchars($anounce->ville).'<br>'; } $prev_anounce = $anounce->id; } if ($anouncement) { } ?>