php - How to call while loop from class? -


i have class getinfo.php , script welcome.php. inside info class have function getall. want call "first" variable $this->first , returning 1 value, want "first" in row.please see below

    //script getinfo.php class getinfo{      function getall(){              global $conn;             $sql = $conn->prepare("select * users");             $sql->execute();             while($row = $sql->fetch(pdo::fetch_assoc)){             $this->first = $row['first'];             $this->last = $row['last'];             $this->email = $row['email'];             }          } }         //script welcome.php       <?php       $info = new getinfo();       $info->getall();       echo $info->first;       //this returning 1 value, want row values.       ?> 

make list of array

    class getinfo{         function getall(){             global $conn;             $sql = $conn->prepare("select * users");             $sql->execute();             while($row = $sql->fetch(pdo::fetch_assoc)){                 $this->first[] = $row['first'];                 $this->last[] = $row['last'];                 $this->email[] = $row['email'];             }             return $this;         }     } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -