Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde, consegui adaptar este código ao meu relatório em php, porem não esta listando todo relatório, apenas a primeira linha...como eu faço para ele trazer todos os registros?
segue código.
<?php
$html='
<html>
<body>
';
$html.='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/relatorio.css">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style type="text/css">
.centro {
text-align: center;
}
.negrito {
font-weight: bold;
}
</style>
</head>
<body>
<?php if(!empty($clientes)):?>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" rowspan="2"><img src="../fotos/logo-c4.png" width="126" height="126" /></td>
<td width="80%"><h3 class="centro">Igreja Evangélica Assembleia de Deus - Campo 4</h3></td>
<td width="10%" rowspan="3"><img src="../fotos/comadesma.jpg" width="125" height="112" /></td>
</tr>
<tr>
<td height="37"><h3 class="centro">Endereço: Rua </h3></td>
</tr>
<tr>
<td height="20"> </td>
<td><h3 class="centro"><span class="negrito">Relatório de Membros</span></h3></td>
</tr>
</table>
<p> </p>
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#DDDDDD"><strong>Cód.</strong></td>
<td bgcolor="#DDDDDD"><strong>Nome.</strong></td>
<td bgcolor="#DDDDDD"><strong>Pastor</strong></td>
<td bgcolor="#DDDDDD"><strong>Celular</strong></td>
<td bgcolor="#DDDDDD"><strong>Área</strong></td>
</tr>
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$ver['id'].'</td>
<td>'.$ver['nome'].'</td>
<td>'.$ver['pr_congregacional'].'</td>
<td>'.$ver['celular'].'</td>
<td>'.$ver['area'].'</td>
</tr>
<?php endforeach;?>
</table>
<?php else: ?>
<?php endif; ?>
<div class="footer" align="center">
</div>
</body>
</html>
ajude aew alguém!>
10 horas atrás, wootzor disse:
Onde está definida a variável $clientes?
Aqui!
{
// Recebe o termo de pesquisa se existir
$termo = (isset($_GET['termo'])) ? $_GET['termo'] : '';
// Verifica se o termo de pesquisa está vazio, se estiver executa uma consulta completa
if (empty($termo)):
$conexao = conexao::getInstance();
$sql = 'SELECT id, titulo, data FROM ata';
$stm = $conexao->prepare($sql);
$stm->execute();
$clientes = $stm->fetchAll(PDO::FETCH_OBJ);Em vez de
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$ver['id'].'</td>
<td>'.$ver['nome'].'</td>
<td>'.$ver['pr_congregacional'].'</td>
<td>'.$ver['celular'].'</td>
<td>'.$ver['area'].'</td>
</tr>
<?php endforeach;?>
Não seria?:
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$cliente['id'].'</td>
<td>'.$cliente['nome'].'</td>
<td>'.$cliente['pr_congregacional'].'</td>
<td>'.$cliente['celular'].'</td>
<td>'.$cliente['area'].'</td>
</tr>
<?php endforeach;?>>
Em 29/10/2017 at 10:03, wootzor disse:
Em vez de
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$ver['id'].'</td>
<td>'.$ver['nome'].'</td>
<td>'.$ver['pr_congregacional'].'</td>
<td>'.$ver['celular'].'</td>
<td>'.$ver['area'].'</td>
</tr>
<?php endforeach;?>
Não seria?:
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$cliente['id'].'</td>
<td>'.$cliente['nome'].'</td>
<td>'.$cliente['pr_congregacional'].'</td>
<td>'.$cliente['celular'].'</td>
<td>'.$cliente['area'].'</td>
</tr>
<?php endforeach;?>
Bom dia, eu alterei para este veja.
<?php
//Definindo os dados para conexão e seleção da base de dados
define('DB','comadesma');
define('USER','root');
define('SENHA','');
define('HOST','localhost');
//Conexão com o banco de dados com base nos dados fornecidos anteriormente.
$conexao = mysql_connect(HOST,USER,SENHA)or die('Erro na conexão - '.mysql_error());
($conexao) ? mysql_select_db(DB, $conexao) : die(mysql_error());
//$termo = (isset($_GET['termo'])) ? $_GET['termo'] : '';
$id = isset($_GET['id']) ? (int)$_GET['id'] : '';
//Query simples para busca dos dados
$busca = mysql_query("SELECT * FROM congregacoes")or die(mysql_error());
//Verificação das linhas encontradas.
$ver = mysql_fetch_array($busca);
?>
esta assim !Este é o código completo.
<?php
require 'topo_relatorios.php';
require '../../Connections/conexao.php';
$termo = (isset($_GET['termo'])) ? $_GET['termo'] : '';
//$id = isset($_GET['id']) ? (int)$_GET['id'] : '';
if (empty($termo)):
$conexao = conexao::getInstance();
$sql = 'SELECT id, nome, pr_congregacional, celular, area FROM congregacoes';
$stm = $conexao->prepare($sql);
$stm->execute();
$clientes = $stm->fetchAll(PDO::FETCH_OBJ);
endif;
//Query simples para busca dos dados
//$busca = mysql_query("SELECT * FROM congregacoes")or die(mysql_error());
//Verificação das linhas encontradas.
//$ver = mysql_fetch_array($busca);
?>
<?php
$html='
<html>
<body>
';
$html.='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/relatorio.css">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style type="text/css">
.centro {
text-align: center;
}
.negrito {
font-weight: bold;
}
</style>
</head>
<body>
<?php if(!empty($clientes)):?>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" rowspan="2"><img src="../fotos/logo-c4.png" width="126" height="126" /></td>
<td width="80%"><h3 class="centro">Igreja Evangélica Assembleia de Deus - Campo 4</h3></td>
<td width="10%" rowspan="3"><img src="../fotos/comadesma.jpg" width="125" height="112" /></td>
</tr>
<tr>
<td height="37"><h3 class="centro">Endereço: Rua </h3></td>
</tr>
<tr>
<td height="20"> </td>
<td><h3 class="centro"><span class="negrito">Relatório de Membros</span></h3></td>
</tr>
</table>
<p> </p>
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#DDDDDD"><strong>Cod.</strong></td>
<td bgcolor="#DDDDDD"><strong>Nome.</strong></td>
<td bgcolor="#DDDDDD"><strong>Pastor</strong></td>
<td bgcolor="#DDDDDD"><strong>Celular</strong></td>
<td bgcolor="#DDDDDD"><strong>Area</strong></td>
</tr>
<?php foreach($clientes as $cliente):?>
<tr>
<td>'.$cliente['id'].'</td>
<td>'.$cliente['nome'].'</td>
<td>'.$cliente['pr_congregacional'].'</td>
<td>'.$cliente['celular'].'</td>
<td>'.$cliente['area'].'</td>
</tr>
<?php endforeach;?>
</table>
<?php else: ?>
<?php endif; ?>
<div class="footer" align="center">
</div>
</body>
</html>
não esta funcionando agora depois que fiz as alterações...
Resolvido!
Onde está definida a variável $clientes?