I'm developing an ad system, where you can submit offers to the ad owner and then approve or reject the offer, if you approve and then negotiate with the offerer.
I came across a problem: When I have only one offer I can approve or reject, but if I have more than one offer when I click on an option it does it for all offers ...
I searched the forum, but I did not find anything like it.
Follow the code (obs: when I threw the code here it messed up the indentation):
<div class="container2">
<div class="col-sm-10">
<div class="row">
<div class="titulo_1">
<h1>Ofertas recebidas</h1>
</br>
</div>
<?php
$id_usuario = $_SESSION["id"];
$anuncio = $_GET["id"];
$sql = "SELECT * FROM ofertas = OF
INNER JOIN anuncios = AN
ON OF.id_anuncio = AN.ID
WHERE AN.id_usuario = '$id_usuario' AND OF.status = 'ANALISE'";
while($sql = mysql_fetch_array($query2))
{ ?>
<div class="col-sm-3">
</br>
<div class="text-center"><strong>ID do usuário que enviou a oferta: </strong><?php echo $sql['id_usuario_oferta']; ?></div>
<div class="text-center"><strong>ID da oferta: </strong><?php echo $sql['ID_OF']; ?></div>
<div class="text-center"><strong>ID do anúncio: </strong><?php echo $sql['ID']; ?></div>
<div class="text-center"><strong>Usuário que enviou a oferta: </strong><?php echo $sql['nomeusuario_oferta']; ?></div>
<div class="text-center"><strong>Produto: </strong><?php echo $sql['produto']; ?></div>
<div class="text-center"><strong>Valor oferta: </strong><?php echo $sql['valoroferta']; ?></div>
<div class="text-center"><strong>Valor de recompensa que você informou: </strong><?php echo $sql['valorrecompensa']; ?></div>
<div class="text-center"><strong>Viagem que ele irá fazer: </strong><?php echo $sql['viagemcompra']; ?></div>
<div class="text-center"><strong>Comentário: </strong><?php echo $sql['comentario']; ?></div>
<div class="text-center"><strong>Oferta enviada em: </strong><?php echo $sql['dataoferta']; ?></div>
</br>
<form method="post" action="">
<button type="submit" name="aceitar" id="aceitar" value="NEGOCIACAO"class="btn btn-success btn-flat">Aceitar</button>
<button type="submit" name="rejeitar" id="rejeitar" value="REJEITADO" class="btn btn-danger btn-flat">Rejeitar</button>
</form>
<?php
$IDoferta = $sql['ID_OF'];
if(isset($_POST['aceitar'])) {
$query = "UPDATE ofertas SET status = 'NEGOCIACAO' WHERE ID_OF = '$IDoferta'";
mysql_query($query);
echo "<meta http-equiv='refresh' content='0, url=index.php'";
} ?>
<?php
$IDoferta = $sql['ID_OF'];
if(isset($_POST['rejeitar'])) {
$query = "UPDATE ofertas SET status = 'REJEITADO' WHERE ID_OF = '$IDoferta' LIMIT 1";
mysql_query($query);
echo "<meta http-equiv='refresh' content='0, url=index.php'";
} ?>
</div>
<?php
} ?>
</div>