Afficher les 10 derniers membres inscrits

Par Cruwp, il y a 15 ans


Bonjour,
Je suis en train de créer un forum et j'ai un problème avec ma requete pour afficher la liste des membres, je souhaite afficher les 10 derniers membres inscrits.
Voici la requête :

$sql = "SELECT * FROM membres BY id DESC 0,10";
$req = mysql_query($sql) or die(mysql_error);

L'erreur :

Notice: Use of undefined constant mysql_error - assumed 'mysql_error' in C:\wamp\www\forum\membres.php on line 38
mysql_error

Merci

Cruwp

4 réponses

Cruwp, il y a 15 ans

ah oui merci
ça marche

Grafikart, il y a 15 ans

mysql_error() c'est une fonction tu as oublié les ()

Cruwp, il y a 15 ans

J'ai une nouvelle erreur

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY id DESC 0,10' at line 1

La requête :

$sql = "SELECT * FROM membres BY id DESC 0,10";
$req = mysql_query($sql) or die(mysql_error());
fl0_9, il y a 15 ans

Il y a une erreur dans ta requête SQL.
Il faut que tu mette ça

$sql = "SELECT * FROM membres ORDER BY id DESC LIMIT 0,10"

Normalement ça devrait marcher. Et pour les afficher tu utilise le while.