I’m using unity wiki for my high-score leader-board i just want to know what i have to put in to it so it will display rank number , since it shows name and score but not the the numbers of ranking. i want to know how to display the numbers.
CREATE TABLE scores ( id int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(15) NOT NULL DEFAULT ‘anonymous’, score int(10) UNSIGNED NOT NULL DEFAULT ‘0’
)
TYPE=MyISAM;
Well, the above is only the table schema, which shouldn’t need to change in order to display rank. Basically, you’ll just want to to add an “ORDER BY score DESC” clause to the SELECT statement that’s retrieving the db data. That’ll return the records in ranked order (highest score first). Then, when you step through the resulting records to display them, just increment a local “rank” variable to display with each record’s data.
There may also be some SQL trickery you could use to return each records position number directly from within the SELECT statement, though I’m not sure.
I thought rank wasn’t working. If rank is working, what’s the question again? Assuming rank isn’t working, my previous reply should be helpful. What does the code look like that retrieves the database info and displays the names and scores?
ya everything is working so names show up score shoes up based on rank but only name and score can be seen no numbers as of the ranking number
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
OK, so in the above code snippet (from your code), the $i variable is basically your rank (though you’ll want to add 1 to it). So, in this statement:
echo $row['name'] . "\t" . $row['score'] . "\n";
You just need to display the value of “i + 1”. That should be quite easy to do, though my PHP is really rusty, so I’m not sure about the syntax. Maybe something as simple as:
Can you show us what the result looks like? Each column should still be separated by a tab character (the “\t” in the code). The only thing I questioned was whether PHP would properly parse the “$i + 1” portion of the statement within the echo. I certainly expected what was working to continue to work.
In addition to showing the results, can you show your current version of the modified code?
in gui text works but in when i press play button the scores go on left side and sites on the names , just the display i guess looks bad but in gui text example : 1 marko 445
when pressed play example : 445 on top of marko and 1 is on 445 i can oly bring 1 to the right side . and 445 is still on top of marko
Hmmm… I’m doing my best to help, but I’m really having a hard time understanding what you’re getting at. Unfortunately, each post seems to make things less clear for me…
I thought things were “mostly” working in your previous post, though it seemed as if you had some sort of formatting issue. Now, you’re showing both Unity code and some PHP code. I’m not sure what one has to do with the other, or why you’ve introduced the Unity code into the current discussion.
If you can show me what you’re seeing on the screen when you said “actually did work but all the numbers are together and inside the name with out any space”, I might be able to help. Otherwise, I’m not so sure.
Please, try to be as clear as possible when seeking help.
Hmmm… Web development isn’t my strong suit, but I think the problem is this… The PHP code (specifically, the echo statement) is only emitting HTML content that’s ultimately displayed by the browser. I’m not sure if a tab character (at least in the form of “\t”) would be properly interpreted in HTML - which tends to compress extra whitespace.
I just took a quick look at HTML entity characters and don’t see a representation for TAB, though maybe I missed it. Bottom line, in order to display your data in 3 columns as you want, and position those columns beneath their respective labels (generated from a Unity GUI element), you’re going to need something more than just a string separated by tab characters.
Likely, you’ll either need to output the data within a HTML table or use some CSS to properly format your output.
But, again, I’m not a web-dev expert. Maybe someone with more knowledge in this area can chime in…
Another idea would be to get the actual score data inside of Unity, and output the screen content from Unity instead of PHP…