[PHP-MySql] ORDER BY quand plusieurs LIMIT

Résolu
Bonjour,

Voilà ! J'ai une question à vous poser... je bloque sur des requêtes sql... Ma table à un champ id auto_increment...

Je développe un site web pour mon père, j'ai donc créé une petite album photo, le problème est que les photos s'affiche par l'ordre d'entrer dans la base mysql et je voudrais que ce soit par id... voici le code qui permet l'affichage des images
$p = $_GET['p'];
if(empty($p)) { $p = 0; } else { $p = ($p-1)*12; }							  
$j = ($p);
echo '<tr>';
$ss = ' SELECT * FROM `photos` LIMIT '.$j.', 4';
$ll = mysql_query( $ss );
while($data = mysql_fetch_array($ll))
{
	echo '<td width="25%" align="center">
		<a href="box.php?width=1000&height=450&pic='.$data['id'].'" class="thickbox" target="_blank" title="Cliquez pour agrandir">
		<img src="image.php?width=210&height=300&image='.$data['large'].'" width="186px;"/></a>';
	if(admin(cachépoursecurité))
	{
		echo '<br /><a href="editpicture.php?mod='.$data['id'].'">Modifier</a><br /><a href="editpicture.php?del='.$data['id'].'">Supprimer</a>';
	}
	echo'</td>';
}
echo '</tr>';
$j = ($p)+4;
echo '<tr>';
$ss = ' SELECT * FROM `photos` LIMIT '.$j.', 4';
$ll = mysql_query( $ss );
while($data = mysql_fetch_array($ll))
{
	echo '<td width="25%" align="center">
		<a href="box.php?width=1000&height=450&pic='.$data['id'].'" class="thickbox" target="_blank" title="Cliquez pour agrandir">
		<img src="image.php?width=210&height=300&image='.$data['large'].'" width="186px;"/></a>';
	if(admin(cachépoursecurité))
	{
		echo '<br /><a href="editpicture.php?mod='.$data['id'].'">Modifier</a><br /><a href="editpicture.php?del='.$data['id'].'">Supprimer</a>';
	}
	echo'</td>';
}
echo '</tr>';
$j = ($p)+8;
echo '<tr>';
$ss = ' SELECT * FROM `photos` LIMIT '.$j.', 4';
$ll = mysql_query( $ss );
while($data = mysql_fetch_array($ll))
{
	echo '<td width="25%" align="center">
		<a href="box.php?width=1000&height=450&pic='.$data['id'].'" class="thickbox" target="_blank" title="Cliquez pour agrandir">
		<img src="image.php?width=210&height=300&image='.$data['large'].'" width="186px;"/></a>';
	if(admin(cachépoursecurité))
	{
		echo '<br /><a href="editpicture.php?mod='.$data['id'].'">Modifier</a><br /><a href="editpicture.php?del='.$data['id'].'">Supprimer</a>';
	}
	echo'</td>';
}
echo '</tr>';
echo '</table>';
Configuration: Windows XP
Firefox 3.5.2

2 réponses

  1. Contributeur
    Et tu ne peux pas juste rajouter un ORDER BY id DESC à la fin de tes requetes?
    1
    1. Euh merci :D je savais que cétais juste ça !
      0