0
I’m having problems in a while loop where it has a function mysql_fetch_assoc
that redeems a value from a column in a table called orders in the delivered column.
I made a if
to see if there’s a yes’s in the delivered column, that made some changes with Javascript that changes some colors and put a button written 'order already delivered' that when clicked puts a value’s' in the column delivered in the order table.
The big problem in the code is that if you click on the 'order already delivered' button of the last recovered line, even if the other lines don’t have the’s' they get Javascript tagging I made as if it was already ordered delivered.
<?php
include 'conn.php';
$query_select = "SELECT cliente.id_cliente, cliente.nome, cliente.telefone, cliente.endereco, cliente.bairro, cliente.email, pedidos.id_pedido, pedidos.produto, pedidos.qtde, pedidos.preco,
pedidos.registro, pedidos.observ, pedidos.datahr, pedidos.entregue FROM cliente, pedidos WHERE cliente.id_cliente = pedidos.id_cliente";
$result = mysql_query($query_select, $connect);
if(mysql_num_rows($result) == 0){
echo '<div class="sem-pedidos">Sem pedidos para Acompanhamento.</div>';
exit;
}
while ($row=mysql_fetch_assoc($result)) {
?>
<div class="pedido">
<div class="nome-cliente" style="width:250px; float:left"><strong><?php echo mb_strtoupper($row['nome']); ?></strong></div>
<div class="registered" style="width:300px;float:left"><i>Registrado por <?php echo $row['registro'];?> em <?php echo $row['datahr'];?></i></div>
<div class="telefone" style="width:200px;"><strong><?php echo $row['telefone']; ?></strong></div>
<div class="email" style="width:200px;"><?php echo $row['email']; ?></div>
<div class="produto"><?php echo $row['produto']; ?></div>
<div class="endereco"><?php echo $row['endereco']; ?></div>
<div class="bairro"><?php echo $row['bairro']; ?></div>
<div class="qtde" style="float:left"><strong>Qtde. </strong><?php echo $row['qtde']; ?></div>
<div class="preco"><?php echo $row['preco']; ?></div>
<div class="observ"><strong><i>OBS. <?php echo $row['observ']; ?></i></strong></div>
<div class="status" id="status"><strong>Status:</strong><span class="carrega-status"> Entrega em aberto</span></div>
<div class="field">
<a href="entregue.php?id_pedido=<?php echo $row['id_pedido']; ?>" title="clique se pedido ja foi entregue ao cliente">
<img src="bt.jpg" />
</a>
</div><!-- fim div class field -->
<?php
if($row['entregue'] == "s"){
echo '<script>
$(".field").remove();
$(".carrega-status").addClass("entregue");
$(".carrega-status").html(" Pedido ja Entregue");
$(".pedido").addClass("entregue-ok");
</script>';
}
?>
</div><!-- fim div class pedido -->
<?php
// finaliza o loop
}
Why should we not use mysql type functions_*?
– Jorge B.