0
I have a code that searches the data in the database and prints on the screen a table. My table that appears on the user screen has the fields:
Referência | Abertura |Status |Objeto
Reference is an ID, Open is a date and time, Status is a string
and Object is a text.
This table above, search the database the "notices" registered by the administrator, in another screen. In this screen of the registration of notices, I made another table in the database that records the status that was and the status that became and to show and print on the screen when the user(Adm) makes a change of Status.
In the table that prints(above) the data that user needs to know, I need the Status to disappear from that table after 30 days when it is changed to Unsuccessful or Revoked.
How were two tables in the bank, different, when I did the select
i had to do a sub-select to bring the status data changed and the date of the last change.
After that I made one if
to test if the status changed has date less than 30 days from today but did not work this way:
// $dados um mysql_fetch_array com o dados do select que eu fiz //
if ( ( $dados['status_alterado'] === "Sem Sucesso") && ( $dados['data'] <= date("m-d-Y") - 30) ) {
echo 'olar';
}
else {
echo 'oi';
}
I did exactly that if
, but he always falls in else
, i already changed in the bank a data I entered as test today 25/03/2015 for 25/01/2015, but even so the if
jumps to the else
.
Put the diagram of the table and some results, so we have how to see the data and understand how to correct the date function
– Fernando Cordeiro
That one
if
has syntax problems in parentheses. I think it should beif (($dados['status_alterado'] === "Sem Sucesso") && ($dados['data'] <= date("m-d-Y") - 30)) {
. Besidesdate("m-d-Y") - 30)
is confused, what do you want to do with that comparison? take 30 days to date? or 1 month? however that is not the way. Explain a little better so we can help more.– Sergio
my correct if is this: [link] if ( ($notices['status'] == "Unsuccessful") && ($notices['data'] + 30 <= date("Y-m-d"))
– Estácio Di Fabio