Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Can anyone help with some PHP/SQL

  • 30-10-2013 7:58pm
    #1
    Registered Users, Registered Users 2 Posts: 454 ✭✭


    Hi,

    I'm working on a server side high-score table for a game, which feeds the players name and their score into a c# script.

    Have a basic implementation working, but I want to add a character after name and score ("/" would do nicely), so I can split up the returned string and present it in a more appealing way. Can anyone show me how to do this? I've attached the code below, thanks.
    <?php
        // Send variables for the MySQL database class.
        $database = mysql_connect('123.456.789.012', 'username', 'password') or die('Could not connect: ' . mysql_error());
        mysql_select_db('xyz_scores') or die('Could not select database');
     
        $query = "SELECT * FROM `scores` ORDER by `score` DESC LIMIT 5";
        $result = mysql_query($query) or die('Query failed: ' . mysql_error());
     
        $num_results = mysql_num_rows($result);  
     
        for($i = 0; $i < $num_results; $i++)
        {
             $row = mysql_fetch_array($result);
             echo $row['name'] . "\t" . $row['score'] . "\n";
        }
    ?>
    


Comments

  • Moderators, Category Moderators, Computer Games Moderators Posts: 51,614 CMod ✭✭✭✭Retr0gamer


    Pretty sure you can just concatenate it in:

    echo $row . "\t".'/'. $row . "\n".'/';

    PHP mysql has been my life for the last few weeks, never learned them before!


  • Registered Users, Registered Users 2 Posts: 3,831 ✭✭✭Torakx


    Nice to see this type of activity here!
    I am very interested in using networking for a game I may be doing serious development with soon.
    But I have so far chosen C#(with Unity) because I have a very vague feeling that it may be usefull for this networking idea too.
    Basically either a server for fps game or p2p client.

    Am I heading in the right direction with that?
    I started doing programming because it was the only way to actually get things to happen in the engines I was working on, to allow me to push the 3D stuff I enjoy and see it working.

    Can C# be used for what I need?
    Or should I be considering using some of the above in the future too?

    I hope the OP issue was resolved, as I don't want to intrude on this thread.My query doesn't seem big enough to make a whole new thread on it, and bump all the others down...
    Hoping for a quick yes no answer, maybe.
    Thanks and good luck!


  • Registered Users, Registered Users 2 Posts: 10,299 ✭✭✭✭BloodBath


    Maybe try using something like this. At least it will be a guideline for what you need to do.

    https://www.assetstore.unity3d.com/#/content/1786


  • Registered Users, Registered Users 2 Posts: 454 ✭✭Kilgore__Trout


    Retr0gamer wrote: »
    Pretty sure you can just concatenate it in:

    echo $row . "\t".'/'. $row . "\n".'/';

    PHP mysql has been my life for the last few weeks, never learned them before!

    Thanks, that did the trick!


  • Registered Users, Registered Users 2 Posts: 454 ✭✭Kilgore__Trout


    Torakx,

    Haven't looked into this much, but I'm guessing that any of the Unity languages should be fine for adding multiplayer. Think Unity uses Raknet by default for multiplayer. I'm probably just going to stick with local co-op this time around (assuming I can get that to work!)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,831 ✭✭✭Torakx


    Keep us updated please!
    I am always interested to hear how other peoples work is going.


  • Moderators, Category Moderators, Computer Games Moderators Posts: 51,614 CMod ✭✭✭✭Retr0gamer


    php would be the one to use for pulling information off a database. It happens server side so you can make it quite secure.


Advertisement