php - Get fetchall result from different class -


let me explain i'm trying do.

in 1 dbcommand.php file have :

class dbcommand extends pdodb {       public function selectall() {        $stmt = $this->dbh->prepare("select hwid,username,pcname users");        $stmt->execute();        $columnn = array();        $result_returned = $stmt->fetchall(pdo::fetch_class);        foreach($result_returned $key=>$result) {          $columnn['hwid'] = $result->hwid;          $columnn['username'] = $result->username;          $columnn['pcname'] = $result->pcname;          //return $columnn;          //$columnn= new us($result->hwid,$result->username,$result->pcname);        }        return $columnn;      } } 

and i'm trying result on page called view.php

$cmd = new dbcommand(); //$get = $cmd->getinfo('1234'); $result=$cmd->selectall();  echo '<tr ><td ><input type="checkbox" class="checkthis" /></td><td>' . $result['hwid'] . '</td><td style="cursor:pointer;" onclick="alert(\'ok\')">' . $result['username'] . '</td><td style="cursor:pointer;" onclick="alert(\'ok\')">' . $result['pcname']. '</td><td><p data-placement="top" data-toggle="tooltip" title="edit"><button class="btn btn-primary btn-xs" data-title="edit" data-toggle="modal" data-target="#edit" ><span class="glyphicon glyphicon-download-alt" onclick="myajax()"></span></button></p></td>   <td><p data-placement="top" data-toggle="tooltip" title="delete"><button class="btn btn-danger btn-xs" data-title="delete" data-toggle="modal" data-target="#delete" ><span class="glyphicon glyphicon-trash"></span></button></p></td> </tr>';                                         ?> 

the issue have , selectall works , view.php 1 info it, either first 1 or last one.

even if try make kind of while on view.php part, never result.

lets selectall return array('123','azerty',azerty'); , array('6547','qwertty',qwerty'); , print_r selectall show me want see, result view.php, show me 1 of these 2 result.

--

i tried create class takes $this->_hwid, i'll use class later, didnt manage, since object in string result.

--

getting stuck, help.

your foreach fills 1 item in array.

try instead:

 foreach($result_returned $key=>$result) {    $columnn[$key]['hwid'] = $result->hwid;    $columnn[$key]['username'] = $result->username;    $columnn[$key]['pcname'] = $result->pcname;  } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -