Reputation: 518
I have some data in this mysql table, but it is not showing anything in the html table.
But I am almost sure that the code is not wrong.
(Obs: I am using the "Smarty PHP Template", just to not mix html with php)
Another observation, i did not paste the full code of (pesquisa.tpl).
Imagine that aluno=user and pesquisa=search
-> pesquisa_aluno.class.php
<?php
class PesquisaAluno {
private $nome;
private $sobrenome;
private $rg;
private $email;
private $telefone;
public function __construct($nome, $sobrenome, $rg, $email, $telefone) {
$this->nome = $nome;
$this->sobrenome = $sobrenome;
$this->rg = $rg;
$this->email = $email;
$this->telefone = $telefone;
}
public function getNome() {
return $this->nome;
}
public function getSobrenome() {
return $this->sobrenome;
}
public function getRg() {
return $this->rg;
}
public function getEmail() {
return $this->email;
}
public function getTelefone() {
return $this->telefone;
}
}
?>
-> pesquisa.php
<?php
include("classes/pesquisa_aluno.class.php");
$alunos = array();
foreach ($connection->query("SELECT * FROM alunos") as $row) {
$aluno = new PesquisaAluno($row["nome"], $row["sobrenome"], $row["rg"], $row["email"], $row["telefone"]);
$alunos[] = $aluno;
}
$smarty->assign('alunos', $alunos);
?>
-> pesquisa.tpl
{foreach from=$alunos item=aluno}
<tr>
<td>{$aluno->getNome()}</td>
<td>{$aluno->getSobrenome()}</td>
<td>{$aluno->getRg()}</td>
<td>{$aluno->getEmail()}</td>
<td>{$aluno->getTelefone()}</td>
</tr>
{/foreach}
Upvotes: 0
Views: 84
Reputation: 6455
In your class you should return $this->telefone;
e.g.:
public function getTelefone() {
return $this->telefone;
}
Edit: did you change it? it said this previously:
public function getTelefone() {
return $telefone;
}
Upvotes: 1