Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MD_Reptile · Jun 02, 2012 at 02:35 AM · androidmysqlphphighscoresserverside

Unify "serverside highscores" - reading in a webpage

Hello all.

I got the unify script for serverside high scores working on my android game, and it will post and get scores from the editor or from the devices without problems.

See here: http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores

The thing I need to do/learn is, how can I setup my webpage to have a table showing these high scores from the MySQL database?

You know something like:

 top scores:
  1. billy 55,000
  2. johnny 45,000
  3. frank 30,000
  4. wallace 1,000

all of that, inside my webpage, so I guess what I need is some HTML/PHP help, in getting the information out of the MySQL database, and making it a readable form in a web browser somehow.

Now I looked into creating a web page with data from MySQL pages, but everything gets so complicated for most peoples databases! Being that my database only holds a name and a score pretty much, the complex tuts I find online dont really apply to me, and are just too far outside of my PHP knowledge in general (why didnt they just make the internet all C# haha). I need something really more geared for us unity people, and that specific serverside high scores MySQL setup...

UPDATE: Okay, I have the answer for those looking to get your high scores onto your webpage(assuming you set them up exactly like the unify community instructs you)...see answer below

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hijinxbassist · Jun 02, 2012 at 04:17 AM 0
Share

@$$anonymous$$DReptile You can go to a webpage that does this and rt click-view source. That shows the source code(as im sure you know) and you can see how they do it. Im a noob when it comes to that stuff, but looking at others code may help you better understand how they did it.

avatar image MD_Reptile · Jun 02, 2012 at 04:21 AM 0
Share

@hijinxbassist Hello again hijinxbassit! You know, actually thats not a half bad idea, I think i will go into my ad$$anonymous$$ view, and see the HT$$anonymous$$L they use to display it, then just use the same query to the database to arrange the info on my site...ill try this now, but if anybody knows a less...reverse engineered way...lol let me know

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by MD_Reptile · Jun 03, 2012 at 04:57 AM

What you will need to do is this:

  1. Open a blank notepad or similar.

  2. On this notepad, copy the PHP script below.

  3. Change the spots where is says "YourWhatever" to match your database.

  4. For your webpage, in the spot where you want your scores to display, paste this whole thing in, and it will display all the scores in a list, numbered 1 to whatever your lowest score is.

Here is the PHP I used exactly (anywhere saying YourSomething - insert your information for your database there)

 <?php
     // Send variables for the MySQL database class.
     $database = mysql_connect('YourDataBaseURL', 'YourUserName', 'YourPasswordHere') or 
 
 die('Could not connect: ' . mysql_error());
     mysql_select_db('YourDatabaseName') or die('Could not select database');
 
     $query = "SELECT * FROM scores ORDER by `score` DESC";
     $result = mysql_query($query) or die('Query failed: ' . mysql_error());
 
     $num_results = mysql_num_rows($result);  
 
     for($i = 0; $i < $num_results; $i++)
     {
      echo ($i + 1)." ";
          $row = mysql_fetch_array($result);
          echo $row['name'] . "\t" . $row['score'] . "\n";
      echo "<div>\n";
     }
 ?>
 </p>

So with this you should have no problems getting started displaying the unify serverside high scores on your web page! good luck!

Hope this saves a few people the effort of having to dig into PHP a little to get this going. Aside from making it skip a line after displaying info, and numbering each result, this is basically the same as how the game would retrieve scores, and its unlimited. I suppose if you had TONS of entries, you might want to limit it to like 100 or so top scores. This could be accomplished I think, by using LIMIT 100 in this line like so:

  $query = "SELECT * FROM scores ORDER by `score` DESC LIMIT 100";
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hijinxbassist · Jun 03, 2012 at 06:12 AM 0
Share

@$$anonymous$$DReptile Good stuff! One of these days im gonna put this to use bookmarked.

avatar image MD_Reptile · Jun 03, 2012 at 06:16 AM 0
Share

@hijinxbassist no problemo, I ask a lot of the answers, so I must give back haha

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Live chat using MySQL? 0 Answers

How can i connect my unity app made for android to connect with mysql database?,How do i able to make my android app made from Unity connect to Mysql database 0 Answers

PHP HighScore Position 1 Answer

Adding extra information to Server Side Highscores 4 Answers

Android build, wwwform gives ssl.SSLHandshakeException 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges