PHP OOP: How to get database values and return all of them -


i trying results database , return them screen, problem once "echo" value's show up, when use "return" 1 shows up.

i can't use echo because application build on way puts html functions can fill objects , fill content of page.

here code.

public function read() {     $query = "select id, title, description, datetime seminar";     $result = $this->getdb()->query($query);      while(($row = $result->fetchobject()) !== false) {         foreach($row $value) {         return $row->title;         //$this->setdescription($row->description);         //$this->setdatetime($row->datetime);         }     }  } 

now wondering how value's on screen instead of 1 showing now.

public function setseminar($sem_obj) {     $this->sem_obj = $sem_obj; }  public function render() {     $this->content = '         on page can see items.     ';     $this->content .= $this->sem_obj->gettitle();     $this->content .= $this->sem_obj->getdescription();     $this->content .= $this->sem_obj->getdatetime();     //$this->content .= $this->text1->showseminairs();     return $this->content; } 

use array.. push databaseobjects , return that

$temparray=array(); while(($row = $result->fetchobject()) !== false) {        $temparray['title']=$row->title;      $temparray['description']=$row->description;       return $temparray;  }  

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -