-2
I’m having a little problem using If with a Function to show a result.
function estaParaExpirar($data, $dias){
return(strtotime($data) < strtotime("+".$dias. "days") );
}
if (estaParaExpirar($row[11], "10") ||
estaParaExpirar($row[12], "10") || estaParaExpirar($row[13], "10") ||
estaParaExpirar($row[14], "10") ||
estaParaExpirar($row[15], "10") ||
estaParaExpirar($row[16], "10") ||
estaParaExpirar($row[17], "10")) {
$Nome1 = '<p>Nome: '.$row[10].'</p>' ;}
I did a little test with the code @Jader gave.
$row[11] = '0000-00-00';
$row[12] = '2014-08-15';
$row[13] = '2014-08-15';
$row[14] = '2014-08-15';
$row[15] = '2014-08-15';
$row[16] = '2014-08-15';
$row[17] = '2014-08-15';
if (($row[11] != '0000-00-00' and $row[12] != '0000-00-00' and $row[13]
!= '0000-00- 00' and $row[14] != '0000-00-00' and $row[15] != '0000-00-00'
and $row[16] != '0000-00-00' and $row[17] != '0000-00-00')
and ((estaParaExpirar($row[11], "10")) and (estaParaExpirar($row[12], "10")) and
(estaParaExpirar($row[13], "10")) and
(estaParaExpirar($row[14], "10")) and
(estaParaExpirar($row[15], "10")) and
(estaParaExpirar($row[16], "10")) and
(estaParaExpirar($row[17], "10")))) {
Upshot;
echo 'missing more than 10 days'; You are wrong
PS: I changed the code to but I am having trouble showing the result. If the result is 10 above the current date shows no result
if (($row[11] != '0000-00-00' && estaParaExpirar($row[11], "10"))
|| ($row[12] != '0000-00-00' && estaParaExpirar($row[12], "10"))
|| ($row[13] != '0000-00-00' && estaParaExpirar($row[13], "10"))
|| ($row[14] != '0000-00-00' && estaParaExpirar($row[14], "10"))
|| ($row[15] != '0000-00-00' && estaParaExpirar($row[15], "10"))
|| ($row[16] != '0000-00-00' && estaParaExpirar($row[16], "10"))
|| ($row[17] != '0000-00-00' && estaParaExpirar($row[17], "10"))) {
$Nome1 = '<p>Nome: '.$row[10].'</p>' ;}
A space is missing before "days". If not, maybe the date format that comes from your bank is not interpretable by
strtotime
.– bfavaretto
Good morning, what’s the problem? please exchange $Row[xx] for real dates because the problem might be the formatted date.
– Márcio Rossato
What date format are you getting in $Row[11...] ?
– Jader A. Wagner
Dates come in the format: Year-Month-Day (0000-00-00 )
– ChrisAdler
Even with the hard space not working
– ChrisAdler
Can do
var_dump($row);
and ask the question to clarify your code and we can help?– Sergio
1- Place the validation condition (check for empty dates) within your function
estaParaExpirar
. 2- Why lightning you need to compare 7 dates of a database row? Probably your table design is very wrong.– gmsantos
if any of the 7 dates are missing less than 10 days send a message. It will be the email content.
– ChrisAdler
Why are you wearing
and
and&&
instead of||
(or) on duty? In this case yourif
requires all conditions to be met.– bfavaretto
I am trying to make Row[?? ] different from 0000-00-00 and 10 days to complete the condition. And that for all others
– ChrisAdler