Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
bom dia galera! sei que estou pedindo de mais, mas já pesquisei em tudo que é lugar e não estou conseguindo listar minhas contas.
O que eu quero é listar minhas contas por tipo,data e por valores ativo e passivo, já tentei ORDER BY,GROUP BY, mas ele sempre me mostra contas cadastradas com o campo valordeb na listagem de contas ativas.
Alguém pode me ajudar?
Segue uma imagem de como estar a listagem.
/applications/core/interface/imageproxy/imageproxy.php?img=http://img.photobucket.com/albums/v200/Filisteus/exemplotab.jpg&key=383b328ea8795d291aa32a2d0b00634e39a526e3df15352c6ff5e9bec1dcf4d4" alt="Imagem Postada" />
Os arquivos
entrada.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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cadastro</title>
</head>
<body>
<div align="center">
<h1>Controle de Caixa </h1>
</div>
<form id="form1" name="form1" method="post" action="salvar.php">
<table width="711" border="0" align="center">
<tr>
<th width="273" align="left"><pre>NOME</pre></th>
<th width="193" align="left"><pre>TIPO</pre></th>
<th colspan="2" align="left"><pre>RECEBIDO</pre></th>
<th width="89" align="left"><pre>VALOR</pre></th>
</tr>
<tr>
<td height="24"><label>
<input name="nome" type="text" id="nome" size="45" />
</label></td>
<td><label>
<input name="tipo" type="text" id="tipo" size="30" />
</label></td>
<td width="113"><label>
<input name="recebido" type="text" id="recebido" size="15" />
</label></td>
<td width="21">R$</td>
<td><label>
<input name="valor" type="text" id="valor" size="10" />
</label></td>
</table>
<div align="center">
<input type="submit" name="Submit" value="Gravar" style="cursor:pointer"/>
</div></td>
</form>
</body>
</html>debito.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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cadastro</title>
</head>
<body>
<div align="center">
<h1>Controle de Caixa </h1>
</div>
<form id="form1" name="form1" method="post" action="salvardeb.php">
<table width="711" border="0" align="center">
<tr>
<th width="273" align="left"><pre>NOME</pre></th>
<th width="193" align="left"><pre>TIPO</pre></th>
<th colspan="2" align="left"><pre>RECEBIDO</pre></th>
<th width="89" align="left"><pre>VALOR</pre></th>
</tr>
<tr>
<td height="24"><label>
<input name="nome" type="text" id="nome" size="45" />
</label></td>
<td><label>
<input name="tipo" type="text" id="tipo" size="30" />
</label></td>
<td width="113"><label>
<input name="recebido" type="text" id="recebido" size="15" />
</label></td>
<td width="21">R$</td>
<td><label>
<input name="valordeb" type="text" id="valordeb" size="10" />
</label></td>
</table>
<div align="center">
<input type="submit" name="Submit" value="Gravar" style="cursor:pointer"/>
</div></td>
</form>
</body>
</html>salvar.php
<?php
@ini_set('display_errors', '1');
error_reporting(E_ALL);
//pegar a data
$data_conta = date("d-m-Y");
$nome = $_POST["nome"];
$tipo = $_POST["tipo"];
$recebido = $_POST["recebido"];
$valor = $_POST["valor"];
$valor = str_replace(",",".","$valor");
mysql_connect("localhost", "root", "p23e79");
mysql_select_db("caixa");
mysql_query("INSERT INTO contas (id , data_conta , nome , tipo , recebido , valor )
VALUES (NULL , now() , '$nome', '$tipo', '$recebido', '$valor')");
mysql_close();
echo "Salvo com sucesso<br />";
?>
<a href="index.html">Voltar</a>salvardeb.php
<?php
@ini_set('display_errors', '1');
error_reporting(E_ALL);
//pegar a data
$dataconta = date("d/m/y");
$nome = $_POST["nome"];
$tipo = $_POST["tipo"];
$recebido = $_POST["recebido"];
$valordeb = $_POST["valordeb"];
$valordeb = str_replace(",",".","$valordeb");
mysql_connect("localhost", "root", "p23e79");
mysql_select_db("caixa");
mysql_query("INSERT INTO contas (id , data_conta , nome , tipo , recebido , valordeb )
VALUES (NULL , '$dataconta' , '$nome', '$tipo', '$recebido', '$valordeb')");
mysql_close();
echo "Salvo com sucesso<br />";
?>
<a href="index.html">Voltar</a>listar.php
<?php
@ini_set('display_errors', '1');
error_reporting(E_ALL);
mysql_connect("localhost", "root", "p23e79");
mysql_select_db("caixa");
$resultado = mysql_query("select * from contas ORDER BY valor ");
mysql_close();
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Lista de Dados</title>
</head>
<body>
<?php
if(mysql_num_rows($resultado) < 1) {
exit;
}
?>
<table width="799" border="1" align="center">
<tr>
<th width="310">NOME</th>
<th width="131">TIPO</th>
<th width="119">DATA</th>
<th width="119">RECEBIDO</th>
<th width="160">VALOR</th>
</tr>
<?php
$saldo = 0;
while($l= mysql_fetch_array($resultado)) {
$nome = $l["nome"];
$tipo = $l["tipo"];
$data = $l["data_conta"];
$recebido = $l["recebido"];
$valor = $l["valor"];
$valordeb = $l["valordeb"];
$saldo += $l['valor'];
echo"
<tr>
<td>$nome</td>
<td>$tipo</td>
<td>$data</td>
<td>$recebido</td>
<td>$valor</td>
</tr>\n";
}
echo"
<tr>
<td>Total de Saldo é</td>
<td>R$',number_format($saldo,2,",",".")</td>
</tr>\n";
echo"
<tr>
<td>$nome</td>
<td>$tipo</td>
<td>$data</td>
<td>$recebido</td>
<td>$valordeb</td>
</tr>\n";
?>
</table>
</body>
</html>A Tabelacreate table contas(
id int(10) unsigned not null auto_increment,
nome varchar(80) NOT NULL,
recebido char(80) NOT NULL,
tipo char(80) NOT NULL,
valor int(8) NOT NULL,
data_conta date default NULL,
valordeb int(8) NOT NULL,
primary key(id));Carregando comentários...