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

MysQL - Writing player coins&stats

Comments in 'Plugin Development' started by Kvetinac97, Jul 28, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hi.

    How can I:

    0) Create table "name"

    1) Write players name into MysQL database (with empty kills&money)

    2) Write something into players kills/money

    3) Get players money&kill count
    PianoPlayer38 likes this.
  2. DeltaDrizz
    Offline

    DeltaDrizz New Member

    Joined:
    Jul 28, 2015
    Posts:
    2
    Minecraft User:
    DrizzleBeat_98
    Search google for the following MySQL queries:
    1) CREATE TABLE
    2) INSERT INTO
    3) UPDATE SET
    4) SELECT

    The request can be done via $this(Pluginbase)->database->query("Your Query in quotes") if I remember correctly (If not some1 corrects me). Remember that you have e.g. XAMPP installed for database hosting on your local computer.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    $db = new \mysqli("host""user""password""schema"); // save the instance for better performance.
    $db->query("CREATE TABLE IF NOT EXISTS name (name VARCHAR(16), kills INT DEFAULT 0, deaths INT DEFAULT 0)");
    $db->query("INSERT INTO name (name) VALUES ('{$db->escape_string($name)}')");
    $db->query("UPDATE name SET kills=$kills, deaths=$deaths WHERE name='{$db->escape_string($name)}'");
    $db->query("SELECT kills, deaths FROM name WHERE name='{$db->escape_string($name)}'");
    From your question, it seems that you don't understand the concept of a SQL table at all. Please read more about SQL tables.
  4. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I understand MysQL, but only thinks I learned (in something like CodeAcademy) is creating databases from PHPMyAdmin.
    PianoPlayer38 likes this.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    But you don't even what a table is meant for.
  7. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I finished lesson 5/10 ;)
    PianoPlayer38 likes this.

Share This Page

Advertisement