0
My script is a function (query.php) that queries the mysql database and with while I run all object contents ($qr = $query->fetch_object())). If I give a print_r inside I can see all the data but when I try to use the Return to get the data on another page nothing happens.
Thanks in advance.
while($data = $query->fetch_object()){
$data->id;
$data->modelo;
$data->login;
$data->senha;
$data->cadin;
$data->cadin;
$data->status;
$data->idSessao;
$data->dataHora;
print_r($data); //esse print contem todo conteudo
}
print_r($data); //esse print nao contem nada
$this->data = &$data;
return true;
}
In the other file where I get the data have this line:
$lista = $modelObj->data;
//aqui não tenho valor algum
Trecho que usa os dados de return
<?
$modelObj->Consulta();
$lista = $modelObj->var;
//esse print nao tem valor
print_r($lista);
?>
<div class="col200"><?=$lista['id'];?></div>
<div class="col100 center"><?=$lista['modelo'];?></div>
<div class="col100 center"><?=$lista['login'];?></div>
<div class="col100 center"><?=$lista['senha'];?></div>
<div class="col100 center"><?=$lista['cadin'];?></div>
<div class="col100 center"><?if($lista['status'] == 1){echo "Ativo";}else{echo "Desativado";};?></div>
<div class="col100 center"><?=$lista['idSessao'];?></div>
<div class="col100 center"><?=$lista['dataHora']?></div>
<div class="col100 center"></div>
<div class="clear"></div>
vc should make the array and not true and another only the last record is played in date.
– rray
Put the code where you call this function, it’s kind of weird ...
– rray
Take the piece of resolution and create an answer with it :)
– rray