Boa tarde, eu estou montando um sistema de faturas mas estou com problema para exibir os Bancos para Pagamento; a fatura gera corretamente, porem na hora de listar os Bancos cadastrados no sistema: exe: BB, Caixa, Santander, nao lista todos cadastrados, apenas o ultimo cadastrado:
<?php session_start(); ?> <?php include_once("includes/language.php"); ?> <?php include "connection.php"; $sql = "SELECT sistema_bancos.*, sistema_banco_categorias.*, sistema_empresas.* FROM sistema_bancos INNER JOIN sistema_banco_categorias ON sistema_bancos.id_banco_categoria = sistema_banco_categorias.id_banco_categoria INNER JOIN sistema_empresas ON sistema_bancos.id_empresa = sistema_empresas.id_empresa WHERE sistema_empresas.id_empresa = '".$_SESSION["sessaoid"]."'"; $resultado = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($resultado) < 1){ } else{ while($linha = mysql_fetch_array($resultado)){ $banco_categoria = $linha["banco_categoria"]; $cpf_cnpj = $linha["cpf_cnpj"]; $titular = $linha["titular"]; $conta = $linha["conta"]; $agencia = $linha["agencia"]; $operacao = $linha["operacao"]; if($operacao){ if($banco_categoria && $cpf_cnpj && $titular && $conta && $agencia && $operacao){ $bank = "<br /><br />Banco: <b>$banco_categoria</b><br />Agência: <b>$agencia</b><br />Conta: <b>$conta</b><br />Operação: <b>$operacao</b><br />CPF/ CNPJ: <b>$cpf_cnpj</b><br />Favorecido: <b>$titular</b><br /><br />"; } } else{ if($banco_categoria && $cpf_cnpj && $titular && $conta && $agencia){ $bank = "<br /><br />Banco: <b>$banco_categoria</b><br />Agência: <b>$agencia</b><br />Conta: <b>$conta</b><br />CPF/ CNPJ: <b>$cpf_cnpj</b><br />Favorecido: <b>$titular</b><br /><br />"; } } ?> <?php include "connection.php"; $id_fatura = $_GET["id_fatura"]; $sql = "SELECT sistema_faturas.*, sistema_fatura_referencias.* FROM sistema_faturas INNER JOIN sistema_fatura_referencias ON sistema_faturas.id_fatura_referencia = sistema_fatura_referencias.id_fatura_referencia WHERE id_fatura = '$id_fatura'"; $resultado = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($resultado) < 1){ } else{ while($linha = mysql_fetch_array($resultado)){ $id_fatura = $linha["id_fatura"]; $preco = $linha["preco"]; $preco_corrigido = number_format($preco, 2, ',', '.'); $data_emissao = $linha["data_emissao"]; $data_emissao_corrigido = date("d/m/Y", strtotime($data_emissao)); $data_vencimento = $linha["data_vencimento"]; $data_vencimento_corrigido = date("d/m/Y", strtotime($data_vencimento)); $fatura_referencia = $linha["fatura_referencia"]; $descricao = $linha["descricao"]; $br = nl2br($descricao); ?> <?php include "connection.php"; $id_fatura = $_GET["id_fatura"]; $sql = "SELECT sistema_faturas.id_fatura, clientes.*, uf.* FROM sistema_faturas INNER JOIN clientes ON sistema_faturas.id_cliente = clientes.id_cliente INNER JOIN uf ON clientes.id_uf = uf.id_uf WHERE id_fatura = '$id_fatura'"; $resultado = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($resultado) < 1){ } else{ while($linha = mysql_fetch_array($resultado)){ $cliente_cpf_cnpj = $linha["cpf_cnpj"]; $cliente_empresa_cliente = $linha["empresa_cliente"]; $cliente_email = $linha["email"]; $cliente_rua = $linha["rua"]; $cliente_n = $linha["n"]; $cliente_bairro = $linha["bairro"]; $cliente_estado = $linha["estado"]; $cliente_cidade = $linha["cidade"]; ?> <?php $mail = "$cliente_email"; $headers = "MIME-Version: 1.1\n"; $headers .= "Content-type: text/html; charset=UTF-8\n"; $headers .= "From: \"$developer_branch\"<$developer_email>\n"; $headers .= "Reply-To: \"$developer_branch\"<$developer_email>\n"; $message = "<style rel=\"stylesheet\" type=\"text/css\">body{margin:15px; padding:0; text-transform:uppercase;} body, td, input, select{font-family:tahoma; font-size:11px; color:#000000;} .textcenter{text-align:center;} .textright{text-align:right;} .wrapper{margin:0 auto; padding:20px 20px 20px 20px; width:600px; background-color:#ffffff; border:1px solid #ccc; -moz-border-radius:6px; -webkit-border-radius:6px; -o-border-radius:6px; border-radius:6px;} .addressbox{padding:10px; background-color:#ffffff; border:1px solid #ccc; color:#000; overflow:hidden;} table.items{width:100%; background-color:#cccccc; border-spacing:0; border-collapse:separate; border-left:1px solid #cccccc;} table.items tr.title td{margin:0; padding:2px 5px; line-height:16px; background-color:#efefef; border:1px solid #cccccc; border-bottom:0; border-left:0; font-size:12px; font-weight:bold;} table.items td{margin:0; padding:2px; line-height:15px; background-color:#ffffff; border:1px solid #cccccc; border-bottom:0; border-left:0;} table.items tr:last-child td{border-bottom:1px solid #cccccc;} .row{margin:15px 0;} .title{font-size:14px; font-weight:bold;} .bill-button{padding-top:8px; padding-left:24px; padding-right:24px; padding-bottom:8px; background:#8e4949; border:0; outline:0; font-family:arial; font-size:8pt; color:#ffffff; cursor:pointer; letter-spacing:0.2px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; -webkit-transition:background 1s; -moz-transition:background 1s; -o-transition:background 1s; -ms-transition:background 1s; transition:background 1s;} .bill-button:hover{background:#a50c0c; -webkit-transition:background 1s; -moz-transition:background 1s; -o-transition:background 1s; -ms-transition:background 1s; transition:background 1s;}</style><body><div class=\"wrapper\"><table class=\"items\"><tbody><tr><td width=\"100%\"><div class=\"addressbox\"><center><span class=\"title\">FATURA #$id_fatura</span><br /><br />$cliente_empresa_cliente<br />$cliente_cpf_cnpj<br />End. $cliente_rua, $cliente_n - $cliente_bairro<br />$cliente_cidade - $cliente_estado $bank [confirmar depósito bancário/ transferência via e-mail]</center></div></td></tr></tbody></table><br /><table class=\"items\"><tbody><tr class=\"title textcenter\"><td width=\"50%\">Data Emissão</td><td width=\"50%\">Data Vencimento</td></tr><tr><td><center>$data_emissao_corrigido</center></td><td><center>$data_vencimento_corrigido</center></td></tr></tbody></table><br /><table class=\"items\"><tbody><tr class=\"title textcenter\"><td width=\"70%\">Descrição</td><td width=\"30%\">Valor</td></tr><tr><td><center>$fatura_referencia<br /><b>$br</b></center></td><td class=\"text-center\"><font style=\"font-size:12px; font-weight:bold;\"><center>R$ $preco_corrigido</center></font></td></tr><tr class=\"title\"><td class=\"textright\">Sub Total:</td><td class=\"text-center\"><center>R$ $preco_corrigido</center></td></tr><tr class=\"title\"><td class=\"textright\">Total:</td><td class=\"text-center\"><center>R$ $preco_corrigido</center></td></tr></tbody></table></div><br /><center><a href=\"$developer_link\" target=\"_blank\" style=\"outline:0;\"><img src=\"".$developer_link."home/img/signature.png\" border=\"0\" title=\"$developer_branch\" alt=\"$developer_branch\" /></a></center></body>"; $title = "Fatura Gerada | $developer_branch"; ?> <?php } } ?> <?php if(!mail($mail, $title, $message, $headers ,"-r".$developer_email)){ $headers .= "Return-Path: \"$developer_branch\"<$developer_email>\n"; mail($mail, $title, $message, $headers); } ?> <?php } } } } ?> <?php echo "<script type=\"text/javascript\">location.href=\"cadastra_fatura.php\"</script>"; ?>
a listagem dos bancos é no $bank, no caso em vez de listar todos Bancos cadastrados lista apenas o ultimo.