0
Good guys after a long time hitting the head with a certain problem I can solve it in a certain way (gambiarra) but now I need to know how to list data from my database that is of the same id , i add several products in a certain sale and I wanted to list these products only from that sale , I tried to use the while but it returns me a repeated list of the values of my entire table
My code :
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function alguma(e){
if(!confirm("Deseja realmente excluir este registro?"))
cancelOperation(event);
}
function cancelOperation(e){
var evt = e || window.event;
if(evt.preventDefault())
evt.preventDefault();
else
evt.returnValue = false;
}
</script>
</head>
<?php
include("banco.php");
echo'<link rel="stylesheet" type="text/css" href="css/estilo.css">';
echo'<link rel="stylesheet" type="text/css" href="css/bootstrap.css">';
include("banco.php");
$id = $_GET["id"];
$sql = mysql_query("select * from venda where id_venda='$id'");
$exibe = mysql_fetch_assoc($sql);
$perfil=mysql_query("SELECT * FROM venda WHERE id_venda='$id'");
$dados=list($id_venda,$venda,$data,$placa,$km)=mysql_fetch_row($perfil);
$produtos = "SELECT * FROM produtos WHERE id_produto=". $dados[5];
$query = mysql_query($produtos);
$b=mysql_fetch_array($query);
#$id = $b ['id'];
$produtos = $b ['produtos'];
$servicos = "SELECT * FROM servicos WHERE id_servico=". $dados[6];
$query = mysql_query($servicos);
$c=mysql_fetch_array($query);
#$id = $b ['id'];
$servicos = $c ['servicos'];
?>
<label for="nome" style="color: #000"><strong>ID DA VENDA :</strong> </label>
<input type="text" readonly="true" name="id" style="width: 170px" value="<?php echo $dados[0]; ?>">
<div id="camp5">
<label for="nome"readonly="true" style="color: #000"><strong>Nº DA VENDA:</strong> </label>
<input type="text" name="id" readonly="true" style="width: 170px" value="<?php echo $dados[1]; ?>">
</div>
<div id="camp1">
<label for="nome" style="color: #000"><strong>DATA :</strong> </label>
<input type="text" name="id" readonly="true" style="width: 170px" value="<?php echo $dados[2]; ?>">
</div>
<div id="camp6">
<label for="nome" style="color: #000"><strong>PLACA :</strong> </label>
<input type="text" name="id" readonly="true" style="width: 170px" value="<?php echo $dados[3]; ?>">
</div>
<div id="camp2">
<label for="nome" style="color: #000"><strong>KM :</strong> </label>
<input type="text" name="id" readonly="true" style="width: 170px" value="<?php echo $dados[4]; ?>">
</div>
<br><br>
<div id="adicionar">
<a href="adcproduto.php" class="btn btn-info ">ADICIONAR MAIS PRODUTOS <img src="img/add-icon.png"/></a><br><br>
</div>
<label for="nome" style="color: #000"><strong>PRODUTO :</strong> </label>
<input type="text" name="id" style="width: 450px" readonly="true" value="<?php echo $produtos; ?>"><br>
<?php
$selbanco = "SELECT * FROM pedido";
$querybanco = mysql_query($selbanco);
$sql1 = mysql_query("select * from pedido where id_venda='$id'");
$exibe1 = mysql_fetch_assoc($sql1);
$perfil1=mysql_query("SELECT * FROM pedido WHERE id_venda='$id'");
$lista=list($id, $produtos , $idvenda)=mysql_fetch_row($perfil1);
?>
<input type="text" name="id" style="width: 450px" readonly="true" value="<?php echo $lista[1]; ?>"><br>
</body>
</html>
In this part I make to appear the products more only appears the first , and when I tried with the while it returns me all the data of the table, someone knows how I can do it ? :
<?php
$selbanco = "SELECT * FROM pedido";
$querybanco = mysql_query($selbanco);
$sql1 = mysql_query("select * from pedido where id_venda='$id'");
$exibe1 = mysql_fetch_assoc($sql1);
$perfil1=mysql_query("SELECT * FROM pedido WHERE id_venda='$id'");
$lista=list($id, $produtos , $idvenda)=mysql_fetch_row($perfil1);
?>
<input type="text" name="id" style="width: 450px" readonly="true" value="<?php echo $lista[1]; ?>"><br>
I did not understand why the same query is made twice (request)
– rray
So this is kind of the gambit that I did
– Matheus Goes