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

SQL List Problem

Comments in 'Plugin Development' started by Rexius, Apr 13, 2016.

  1. Rexius
    Offline

    Rexius New Member

    Joined:
    Jul 3, 2014
    Posts:
    26
    There are 5 names for 1 player but the message seems to be one

    Sample:
    PHP:
    SQL Table

       p1       p2
    Rexius 
    blabla1
    Rexius 
    blabla2
    Rexius 
    blabla3

    player send messages 
    blabla1,
    I want messages > blabla1, blabla2, blabla3

    PHP:
                            $msg null;
                            foreach(
    $this->getPlayer($player) as $table2 => $p) {
                                if(
    $table2 == 'p2') {
                                    
    $msg .= "$p, ";
                                }
                            }
                            
    $sender->sendMessage($msg);
                            return;

    // and

            
    public function getPlayer($p1) {
                if(
    $this->provider == "SQL") {
                    
    $a $this->db->query("SELECT * FROM player1 WHERE p1='$p1';");
                    
    $b $a->fetchArray(SQLITE3_ASSOC);
                    return 
    $b;
                }
                }
            }
    Bad english, sorry :(
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    if($this->db->error !== null){
       
    $this->getLogger()->warning("MySQL Error $this->db->errno."#: ".$this->db->error);
       
    return;
    }
    $this->db->fetchAssoc($a);
  3. Rexius
    Offline

    Rexius New Member

    Joined:
    Jul 3, 2014
    Posts:
    26
    PHP:
            public function getPlayer($p1) {
                if(
    $this->provider == "SQL") {
                    
    $a $this->db->query("SELECT * FROM player1 WHERE p1='$p1';");
                    
    $b $a->fetchArray(SQLITE3_ASSOC);
                    return 
    $b;
                        if(
    $this->db->error !== null){
                            
    $this->getLogger()->warning("MySQL Error ".$this->db->error);
                            return;
                        }
                    
    $this->db->fetchAssoc($a);
                }
                }
            }
    No error
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    $sql "SELECT * FROM player1 WHERE p1='$p1';";
    if(!
    $r $this->db->query($sql)){
       
    $this->getLogger()->warning("MySQL Error ".$this->db->errorno."#: ".$this->db->error);
    }
  5. Rexius
    Offline

    Rexius New Member

    Joined:
    Jul 3, 2014
    Posts:
    26
    No error o_O
    I want to print side by side :(
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG

Share This Page

Advertisement