2012-01-18 3 views
0

이 mysql 테이블에 일부 데이터가 있지만 html 테이블에 아무 것도 표시하지 않습니다.
하지만 코드가 잘못되어 있지 않은 것으로 확신합니다.쿼리 결과를 표시하는 데 문제가 있음

:
또 다른 관찰 (것을 제외하고 내가 PHP와 HTML을 혼합 단지에의 "멋지 PHP 템플릿"을 사용하고 있습니다), 난 (pesquisa.tpl)의 전체 코드를 붙여하지 않았다. > 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
그 aluno = 사용자와 pesquisa = 검색

을 상상

{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} 
+0

현명한 할당 전에'var_dump ($ alunos)'를 삽입 할 수 있습니까? – DerVO

+0

죄송합니다. PHP 파일을 handler.php 페이지에 포함시키지 않았습니다 ... 실수였습니다. –

+0

@RamonSaraiva -'foreach' 루프가'print_r ($ alunos);'를 사용하여'$ alunos '의 내용을 표시하려고 시도한 후에 비어 있습니까? – Cyclonecode

답변

1

수업 시간에 $ this-> telefone을 반환해야합니다.

예컨대 :

public function getTelefone() { 
    return $this->telefone; 
} 

편집 : 당신이 그것을 변경 했습니까? 그것은 이전에 말했다 :

public function getTelefone() { 
    return $telefone; 
} 
관련 문제