Use variable from a function in another PHP -


i have question. how do rescue variable $row in function listargeral(). can use function editargeral() . tried do, nothing happened

here's tried do:

<?php include ('banco.php');  class geralcontrole {      private $consulta;     private $row = array();      public function geralodao() {         $novaconexao = new banco();         $this->consulta = $novaconexao->conectar();      }      public function listargeral() {          $this->geralodao();         echo '<table border="1" cellspacing="2">         <tr>                 <td>id</td>             <td>cpf</td>         </tr>';          if ($resultado = $this->consulta->query("select * cadastro")) {                  while ($this->row = $resultado->fetch_row()) {                 echo '<tr>                         <td>'.$this->row[0].'</td>                         <td>'.$this->row[1].'</td>                     </tr>';                 echo $this->row[0];             }             $resultado->close();         }            echo '</table>';     }      public function editargeral(){         $this->listargeral();         echo $this->row[0];     } }   $pessoa2 = new geralcontrole(); $pessoa2->listargeral();  $pessoa3 = new geralcontrole(); $pessoa3->editargeral(); 

thank you!

    if ($resultado = $this->consulta->query("select * cadastro")) {                    $rows = array();                  while ($this->row = $resultado->fetch_row()) {                     echo '<tr>                             <td>'.$this->row[0].'</td>                             <td>'.$this->row[1].'</td>                           </tr>                         ';echo $this->row[0];                         array_push($rows, $this->row);                 }                 editargeral($rows); } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -