1
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 field sit 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 will insert the sit 1, follows below my structure.
<?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 so , gave no error more tbm not registered
$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')";
}
if ($string_sql==$string_sql) {
? Missed to take the result of the query and apply on the if, Cade omysql_fetch_assoc()
:P– rray