I'm trying the following: I need the code below to first check that the record that is trying to be finalized (Skip status 1 to 2) is no longer finalized. If you do not follow the NORMAL UPDATE. But what happens is that when I try to finalize a record that is already in the bank with status 2 that is Finalized, it gives the message that it can not finalize and such, but when I try to finalize a record that is active, which is status 1 in the bank and that should then the UPDATE execute and move to 2, nothing happens. Note: (Running only the UPDATE without testing it works normal.)
<?php
@ini_set('display_errors', '1');
error_reporting(E_ALL);
if(file_exists("../config.php")) {
require "../config.php";
} else {
echo "Arquivo config.php nao foi encontrado";
exit;
}
$id = $_GET["id"];
settype($id, "integer");
Abre_Conexao();
//status
if($id){
/*STATUS: 1 = ATIVO, 2 = FINALIZADO*/
$sqlstatus = "SELECT * FROM projetos WHERE STATUS_PROJETO = '2' AND COD_PROJETO = $id";
$resultadost = mysql_query($sqlstatus) or die(mysql_error());
while($linha = mysql_fetch_assoc($resultadost)) {
if($linha['STATUS_PROJETO'] > '0')
echo "Atividade já estava finalizada";
}
} else {
mysql_query("UPDATE projetos SET status_projeto = '2' where cod_projeto = $id");
mysql_close();
header("Location: projetos.php");
}
?>