using of MySQL in Processing
in
Contributed Library Questions
•
6 months ago
Hello,
i'm new using mysql in processing and i have to rank values of my table mysql. So i need to get the score, the login and the rank of each player and to show it in the console until 10.
i did that but it doesn't work, it just shows me :
0 null 0 points (10 times) and i don't know what's wrong with it.
void resumeclassement() {
msql = new MySQL( this, serveur, database, userdb, mdpdb );
efface(0,0,800,600);
if ( msql.connect() ) {
text("CLASSEMENT DES 10 PREMIERS JOUEURS", 350, 30);
int p = 45;
int i = 0;
for (int j = 0; j < 11; j = j + 1) {
msql.query("SET @i:=0");
msql.query("SELECT rank, score, login FROM (SELECT @i:=@i+1 AS rank FROM "+table+" ORDER BY score DESC, LIMIT 1,10");
msql.query("SELECT score FROM "+table+" WHERE rank='"+i+"'");
scoreactuel=msql.getInt(1);
msql.query("SELECT login FROM "+table+" WHERE rank='"+i+"'");
msql.next();
login = msql.getString(1);
text(str(i)+" "+login+" "+str(scoreactuel)+" points",380,p);
p = p+15;}
} else {
text("Problème de connexion a la base de données !!!",400,450);}
}
msql = new MySQL( this, serveur, database, userdb, mdpdb );
efface(0,0,800,600);
if ( msql.connect() ) {
text("CLASSEMENT DES 10 PREMIERS JOUEURS", 350, 30);
int p = 45;
int i = 0;
for (int j = 0; j < 11; j = j + 1) {
msql.query("SET @i:=0");
msql.query("SELECT rank, score, login FROM (SELECT @i:=@i+1 AS rank FROM "+table+" ORDER BY score DESC, LIMIT 1,10");
msql.query("SELECT score FROM "+table+" WHERE rank='"+i+"'");
scoreactuel=msql.getInt(1);
msql.query("SELECT login FROM "+table+" WHERE rank='"+i+"'");
msql.next();
login = msql.getString(1);
text(str(i)+" "+login+" "+str(scoreactuel)+" points",380,p);
p = p+15;}
} else {
text("Problème de connexion a la base de données !!!",400,450);}
}
1