Código PHP:
   $sql = mysql_query("select * from maquinas");
 
while($array=mysql_fetch_array($sql)){
   echo "Registro: ".$array["ip"];
} 
    Pero como lo hago en POO usando mysqli?
Les dejo las clases y todo lo que llevo hecho por si quieren ver como voy
Archivo: php.php
Aqui tengo los métodos y clases
Código PHP:
   <?php
session_start();
date_default_timezone_set("America/Caracas");
 
class Conf{
    private $_user;
    private $_password;
    private $_host;
    private $_database;
    
    static $_instance;
    
    private function __construct(){
        require("config.php");
        $this->_user=$user;
        $this->_password=$password;
        $this->_host=$host;
        $this->_database=$db;
    }
    
    private function __clone(){
    }
    
    public static function getInstance(){
        if(!(self::$_instance instanceof self)){
            self::$_instance = new self;
        }
        return self::$_instance;
    }
    
    public function getUserDB(){
        $var = $this->_user;
        return $var;
    }
    
    public function getHostDB(){
        $var = $this->_host;
        return $var;
    }
    
    public function getPassDB(){
        $var = $this->_password;
        return $var;
    }
    
    public function getDB(){
        $var = $this->_database;
        return $var;
    }
}
 
class Db{
    private $servidor;
    private $usuario;
    private $password;
    private $database;
    private $conex;
    private $result;
    
    static $_instance;
    
    private function setConexion(){
        $conf = Conf::getInstance();
        $this->servidor=$conf->getHostDB();
        $this->database=$conf->getDB();
        $this->usuario=$conf->getUserDB();
        $this->password=$conf->getPassDB();
    }
    
    private function __construct(){
        $this->setConexion();
        try{
            $this->conex = new mysqli($this->servidor, $this->usuario, $this->password, $this->database);
        }catch(Exception $e){
            echo $e->getMessage();
        }
    }
    
    public function ejecutar($sql){
        if(!$this->result = $this->conex->query($sql)){
            printf("Error ejecutando: %s\n", $this->conex->error);
        }
    }
    
    public function getTotalRegistros(){
        return($this->result->num_rows);
    }
    
    public function getRegistro($campobd){
        if($campobd=="*"){
            return($this->result->fetch_array(MYSQLI_ASSOC));
        }else{
            $array = $this->result->fetch_array(MYSQLI_ASSOC);
            return($array[$campobd]);
        }
    }
    
    public static function getInstance(){
        if(!(self::$_instance instanceof self)){
            self::$_instance = new self();
        }
        return self::$_instance;
    }
    
}
 
function getUbicacionCliente(){
 
    $ip=$_SERVER['REMOTE_ADDR'];
    $bd = Db::getInstance();
    $bd->ejecutar("SELECT * FROM maquinas_ubicaciones where ip = '".$ip."' ");
 
    if($bd->getTotalRegistros()>1){
        echo "Direccion IP comprometida";
    }else{
        header("Location://".$bd->getRegistro("url"));
    }
}
 
function logear($post){
    extract($post);
    $bd = Db::getInstance();
    $clave = hash("gost",$clave);
    $bd->ejecutar("SELECT * FROM usuario where clave = '".$clave."' and usuario = '".$usuario."' ");
    
    if($bd->getTotalRegistros() == 1){
        $_SESSION['usuario_id'] = $bd->getRegistro("usuario");
        header("Location://localhost/saas/dashboard/");
    }
}
 
function agregarEmpleado($post){
    extract($post);
    $bd = Db::getInstance();
 
    $bd->ejecutar("insert into empleado (
                                        nombres,
                                        apellidos,
                                        cedula,
                                        direccion,
                                        telefono,
                                        fecha_ingreso,
                                        condicion,
                                        cargo,
                                        salario_base
                                        ) values (
                                        '".$nombres."',
                                        '".$apellidos."',
                                        '".$cedula."',
                                        '".$direccion."',
                                        '".$telefono."',
                                        '".$fecha_ingreso."',
                                        '".$condicion."',
                                        '".$cargo."',
                                        '".$salario."'
                                        )");
}
 
?>    Aqui es donde necesito conseguir todos los registros de empleados con el mismo apellido por decir algo
Código PHP:
   <?php
extract($_GET);
include("../bin/php.php");
 
$bd = Db::getInstance();
 
$bd->ejecutar("select * from empleado where apellido = '".$apellido."' limit 1 ");
 
print_r($bd->getRegistro("*"));
 
while($bd->getRegistro("*")){
    //aqui debo mostrar los registros encontrados y solo me llega a mostrar un registro
}
?>     
 

 ¿Como hago para recorrer un array de registros devueltos mediante MYSQLI?
 ¿Como hago para recorrer un array de registros devueltos mediante MYSQLI? 

 
 



