c# - How to check if ID matches another ID and then display them via a foreach -
not sure how phrase question, i'll try anyway.
i'm working on project want pull out user's highscore via. highscore id in database this:
the user database: |id | username | | 1 | test1 | | 2 | test2 | | 3 | test3 | highscore database: |id |highscore |highscoreid| | 1 | 200 | 1 | | 1 | 230 | 2 | | 1 | 240 | 3 |
first, wish check if the user's id matches id in highscore database (highscoreid), when displaying highscores, test1 (whose id 1) displayed in front of highscore id corresponds id in highscoreid. kind of like;
if(username.id == 1 && highscore.highscoreid == 1) { //display username + score associated username }
i'm not sure how else explain this, when ever wanted display via id websites, have id in address link, , pull out id address link.
i hope explained enough, hitting deadline game, hope dont have rewrite question.
thanks in advance, guys rock.
edit
so basicly this:
mathandyoudbentities db = new mathandyoudbentities(); user users = new user(); highscore highscor = new highscore(); int idcounter = 0; (int = 1; < 5; i++) { = idcounter; if (users.id == && highscor.highscoreid == i) { } }
if want loop through of them can display them later?
d
oing basicly crashes program: mathandyoudbentities db = new mathandyoudbentities(); user users = new user(); highscore highscor = new highscore(); int idcounter = 0; (int = 1; < 5; i++) { = idcounter; if (users.id == idcounter && highscor.highscoreid == idcounter) { allusers += users.bruger.tostring(); highscores += highscor.userhighscore.tostring() + '\n'; } } message = allusers + " " + highscores;
any ideas?
if(username.id == 1 && highscore.highscoreid == 1) { system.out.println("username is: " username.name + "and high score :" + highscore.highscore); //display username + score associated username }
because if checking right username id right highscore, can use same highscore highscore out of it.
i hope making sense!
edit: sorry, didn't read wanted in loop
for(highscore h : highscorelist) //ifyourusinganarraylistnamedhighscorelist if(username.id == 1 && highscore.highscoreid == 1) { system.out.println("username is: " username.name + "and high score :" + highscore.highscore); }
Comments
Post a Comment