3
Good guys I have a table called sale and in this table I insert some data from other table up to there all blz , my problem and at the time of showing this data when I echo a screen does not appear the name of the product but rather the id of it and I need to appear the name , this and my code :
<?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">';
echo '<a href="vendas.php" style="color: #ffffff" class="btn btn-inverse">Cadastrar Vendas</a></br></br>';
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,$produtos,$servicos)=mysql_fetch_row($perfil);
?>
<label for="nome" style="color: #000"><strong>ID DA VENDA :</strong> </label>
<input type="text" readonly="true" name="id" value="<?php echo $dados[0]; ?>">
<label for="nome"readonly="true" style="color: #000"><strong>Nº DA VENDA:</strong> </label>
<input type="text" name="id" readonly="true" value="<?php echo $dados[1]; ?>">
<div id="camp1">
<label for="nome" style="color: #000"><strong>DATA :</strong> </label>
<input type="text" name="id" readonly="true" value="<?php echo $dados[2]; ?>">
<label for="nome" style="color: #000"><strong>PLACA :</strong> </label>
<input type="text" name="id" readonly="true" 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" value="<?php echo $dados[4]; ?>">
<label for="nome" style="color: #000"><strong>PRODUTO :</strong> </label>
<input type="text" name="id" readonly="true" value="<?php echo $dados[5]; ?>">
</div>
<div id="camp3">
<label for="nome" style="color: #000"><strong>SERVIÇO :</strong> </label>
<input type="text" name="id" readonly="true" value="<?php echo $dados[6]; ?>">
</div>
I used the following code to do the id transformation for the name , more like I’m not listing the items does not work :
$produtos = "SELECT * FROM produtos WHERE id=". $dados['produtos'];
$query = mysql_query($produtos);
$b=mysql_fetch_array($query);
#$id = $b ['id'];
$produtos = $b ['produtos'];
Where are you Product and Service that I would like the name to appear and not the id :
First you have to make sure that in the sales table there are the fields with the service and product names. Otherwise you should make a Join in the tables that have these names. A good practice is also to always bring only the fields you will use instead of using the *.
– Joao Paulo