Can i request just 1 score from table of highscores in php?

  • Hi,

    i have created a high-score table in database of a server for my game with the help of this tutorial -

    https://www.scirra.com/tutorials/4839/creating-your-own-leaderboard-highscores-easy-and-free-php-mysql/page-2'

    Now whenever i request php it gives me a list of top scores i.e. names against there scores

    I just wanted to know that is it possible to request just the score against a particular name only?

    For example : I have store this table on server database Rank Name Score

    -------------------------------------------------------------------------------- 1 -------Harry----1000

    -------------------------------------------------------------------------------- 2 -------Sam------700

    --------------------------------------------------------------------------------------------------------------

    -------------------------------------------------------------------------------- 12 -------Monica-500

    Is there a way to request the score against name "monica" only? (by editing code in php_request)

    The php i am currently using is this...

    <?php

    header('Access-Control-Allow-Origin: *');

    $host="localhost"; // Host name

    $username="username"; // Mysql username

    $password="password"; // Mysql password

    $db_name="database"; // Database name

    $tbl_name="scores"; // Table name

    // Connect to server and select database.

    mysql_connect("$host", "$username", "$password")or die("cannot connect");

    mysql_select_db("$db_name")or die("cannot select DB");

    // Retrieve data from database

    $sql="SELECT * FROM scores ORDER BY score DESC LIMIT 10";

    $result=mysql_query($sql);

    // Start looping rows in mysql database.

    while($rows=mysql_fetch_array($result)){

    echo $rows['name'] . "|" . $rows['score'] . "|";

    // close while loop

    }

    // close MySQL connection

    mysql_close();

    ?>

    I have been struggling with this question for a while now, have searched a lot but nothing to help with this.

    Please please kindly help...

    Thank you

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)