Search Unity

Successfully retrieved data from MySQL but how do I control how it displays.

Discussion in 'Scripting' started by AbsoluteZero, Nov 23, 2013.

  1. AbsoluteZero

    AbsoluteZero

    Joined:
    Sep 2, 2013
    Posts:
    19
    Hello everyone,

    I am able to retrieve data from an SQL Database however I still need to control how it looks.

    I retrieve the data using the following PHP code:
    Code (csharp):
    1.          
    2. $query = "SELECT * FROM `highscores` ORDER by `score` DESC LIMIT 5";
    3. $result = mysqli_query($connection, $query) or die('Query failed: ' . mysql_error());
    4.      
    5.          $num_results = mysqli_num_rows($result);  
    6.      
    7.          for($i = 0; $i < $num_results; $i++)
    8.          {     
    9.              $row = mysqli_fetch_array($result);
    10.              echo $row['name'] . "\t" . $row['score'] . "\n";
    11.                  }
    And display it in unity using the following C# code:

    Code (csharp):
    1.         G1.guiText.text = "Loading Scores";
    2.         WWW hs_get = new WWW(highscoreURL);
    3.         yield return hs_get;
    4.  
    5.         if (hs_get.error != null)
    6.         {
    7.             print("There was an error getting the high score: " + hs_get.error);
    8.         }
    9.         else
    10.         {
    11.            G1.guiText.text = hs_get.text; // this is a GUIText that will display the scores in game.
    12.         }
    and it display as so:
    $score.PNG

    Your kind advice is appreciated,

    Thanks,
     
  2. AbsoluteZero

    AbsoluteZero

    Joined:
    Sep 2, 2013
    Posts:
    19
    No one fiddled with gui before ? :(