Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Mysql

Comments in 'Plugin Development' started by JackboyPlay, Feb 13, 2016.

Thread Status:
Not open for further replies.
  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    How ccan i save Things on mysql [Kills] an get Things from mysql [Kills]
    Like /kills add [number] adds the number of kills in the database
    an /kills get [get the killĀ“s from the database]
  2. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Learn MySQL. ;)
    applqpak likes this.
  3. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    And You learn PHP :D
    KubixQ likes this.
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    You have to connect to your database first, you should create a mysqli connection.
    PHP:
    private function getDatabase(){
    return new \
    mysqli("address","user","password","database");
    }
    And, if you want send any, you will have to do a query.
    PHP:
    /*
    * @param Player $player
    */
    $this->getDatabase()->query("UPDATE table SET kills=kills+1 WHERE user=" $player->getName());
    And now, we will get a value with mysqli_fetch_row.
    PHP:
    $getting_info $this->getDatabase()->query("SELECT kills, deaths FROM table WHERE user='AndrewBit4'");
    $getting_info mysqli_fetch_row($getting_info);
    echo 
    $getting_info[0]; // echo AndrewBit4 kills
    echo $getting_info[1]; // echo AndrewBit4 deaths
    But, if you want manage databases (with PHP) as well, you should learn MySQL and improve your PHP with SQL. :) php.net can be your friend, if you need help.
    Last edited: Feb 13, 2016
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There isn't a class called \mysqli_connect. Maybe you meant `new \mysqli()`?
    JackboyPlay likes this.
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Thanks :D
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Thanks, I correct it. :oops:
    JackboyPlay likes this.
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @AndrewBit for what is @param Player $Player and when did I use it? And must I use it?
  9. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @AndrewBit is this possible?
    if($getting_info[0] == 1){
    $event->getPlayer()->sendMessage("Test");
    }
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    And how can i delete the Kills?
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    And the last question must i create a table at beginning? When Yes how?
  12. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    And how can i set the Kills to 0
  13. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I was trying to say that $player should be a instance of Player class.
    Yes.
    Use your brain, if you add 1 kill with kills=kills+1, you can delete they with kills=kills-1.
    Yes... use google.
    kills=0

    Please, if you have multiple questions, ask all in a post... -.-
    applqpak likes this.
  14. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @AndrewBit I Mean how to set the Kills to 0 i know it with the -
  15. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    JackboyPlay likes this.
  16. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  17. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Sorry for this Dump question but how must i make it with the tables and Playernames and e.g?
  18. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    What do you mean?
    If you mean how to do it with other columns, you should do basically the same.
    Example:
    Code:
    UPDATE table SET user='Banned' WHERE isBanned=true
  19. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    And how must i do that for each Player?
  20. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    also how to create a table
Thread Status:
Not open for further replies.

Share This Page

Advertisement