I have a problem. I'm doing an event access control system, I created a table that records the given id, code, date, time, sit, the sit field will be 1 and 2, but I need my system to understand the following. When the last record of the bank is 1 it will insert the sit 2 and when it is 2 it will insert the sit 1, it follows my structure below.
<?php
include"conect_db.php";
$string_sql = mysql_select_db("evento"); //seleciona o banco de dados
//Abaixo atribuímos os valores provenientes do formulário pelo método POS
$string_sql = ("select * from checkout where codigo='06181121978' order by id desc limit 1");
mysql_query($string_sql,$conn); //Realiza a consulta
if ($string_sql==$string_sql) {
$teste = ("INSERT INTO checkout (id,codigo,data,hora,sit) VALUES (null,'06181121978',CURDATE(),curtime(),'1') <> (select * from checkout where codigo='06181121978' AND SIT='2' order by id desc limit 1");
mysql_query($teste,$conn);
}
else{
$teste2 = ("INSERT INTO checkout (id,codigo,data,hora,sit) VALUES (null,'06181121978',CURDATE(),curtime(),'2')");
mysql_query($teste2,$conn);
}
?>
I did it, did not give error more tbm did not register
$string_sql = mysql_select_db("evento"); //seleciona o banco de dados
//Abaixo atribuímos os valores provenientes do formulário pelo método POS
$string_sql = ("select * from checkout where codigo='06181121978' order by id desc limit 1");
mysql_query($string_sql,$conn); //Realiza a consulta
$resultado = mysql_query($string_sql, $conn);
$dado = mysql_fetch_assoc($resultado);
if ($dado['sit'] == '1') {
// insere sit 2
"INSERT INTO checkout (id,codigo,data,hora,sit) VALUES (null,'06181121978',CURDATE(),curtime(),'2')";
}
else {
// insere sit 1
"INSERT INTO checkout (id,codigo,data,hora,sit) VALUES (null,'06181121978',CURDATE(),curtime(),'1')";
}