UPDATE SET in a record [closed]

-3

I have a table that lists records in the database and in front of each record has a button like that

<a href="index.php?mod=pedidos&funcao=editar&id=<?=$lnped['protocolo']?>" class="ls-btn-primary ls-ico-user"></a>

$lnped['protocolo'] comes from the database is the registry number

here's my code

<?php
    $idget = isset($_GET['id']) ? $_GET['id'] : '';
    $produzir = isset($_GET['funcao']) ? $_GET['funcao'] : '';
    $consultapedidos = mysql_query("SELECT * FROM pedidos WHERE protocolo = '".$idget."'");
    if(mysql_num_rows($consultapedidos)==true){
    if($produzir == "editar"){

$sql = mysql_query("UPDATE pedidos SET produzido = '1'") ;  

echo "<meta http-equiv='refresh' content='1;' URL= index.php?mod=pedidos>";
    }
    }
?>
    
asked by anonymous 31.10.2015 / 06:12

2 answers

5

The problem is that your UPDATE does not have a WHERE clause, ie it will update all the records in the database.

For this to work change your UPDATE to:

mysql_query("UPDATE pedidos SET produzido = '1' WHERE protocolo = '".$idget."'");
    
01.11.2015 / 01:19
2
UPDATE pedidos SET produzido = '1' WHERE protocolo = '".$idget."'"
    
31.10.2015 / 12:45