-1
I’m trying to make a logic to display the next day that a particular warehouse will have mailing pouch, I’m trying to create a array
with the quest I’m making in my banco de dados
and trying to ignore today and always see the next day, but without success.
In my bank the days are 0 and 1, and there will be no pouch and 1, yes.
My bank is like this:
My code is like this:
if (GetApplication()->isGetValueSet('IdUnicoop')) { $IdUnicoop = GetApplication()->GetGETValue('IdUnicoop'); $sql = "SELECT * FROM dvsMaloteDias WHERE dvsMaloteDias.IdUnicoop = $IdUnicoop"; $queryResult = $this->GetConnection()->fetchAll($sql); $Notificacao = array(); foreach($queryResult as $RegResult) { if ($RegResult['Segunda'] != 0) { array_push($Notificacao, "Segunda"); } if ($RegResult['Terça'] != 0) { array_push($Notificacao, "Terça"); } if ($RegResult['Quarta'] != 0) { array_push($Notificacao, "Quarta"); } if ($RegResult['Quinta'] != 0) { array_push($Notificacao, "Quinta"); } if ($RegResult['Sexta'] != 0) { array_push($Notificacao, "Sexta"); } if ($RegResult['Sabado'] != 0) { array_push($Notificacao, "Sábado"); } if ($RegResult['Domimgo']!= 0) { array_push($Notificacao, "Domingo"); } if ($RegResult['Todos'] != 0) { array_push($Notificacao, "Todos"); } } $result = array( 'Notificacao' => 'O próximo dia do malote é: ' . $Notificacao ); echo json_encode($result); exit; }
According to the image, for example, the warehouse 9 has pouch on Monday, but I must check what day is today and if it is Monday, I have to show that there will be pouch on Wednesday and Wednesday, check the day and if it is Wednesday, show Friday.
I even managed to find out the day of the week, but the comparison didn’t, look:
$now = new DateTime('now', new DateTimeZone('America/Sao_Paulo')); $minhadataYmdHis = $now->format('Y-m-d'); $diaSemanaN= date("w", strtotime($minhadataYmdHis)); switch($diaSemanaN) { case 0: $diaSemana="Domingo"; break; case 1: $diaSemana="Segunda"; break; case 2: $diaSemana="Terça"; break; case 3: $diaSemana="Quarta"; break; case 4: $diaSemana="Quinta"; break; case 5: $diaSemana="Sexta"; break; case 6: $diaSemana="Sábado"; break; } echo $diaSemana;
Thanks @Matheusprado for the tip, but I didn’t understand the comment about logic, if I’m having trouble with it and so I posted the code that already.
– adventistapr
Usually the problems posted here are errors with functions or syntax or who knows with unexpected problems. If you had a code that already did what you need it to do, but it causes errors or works unexpectedly, it would be another story.
– Matheus Prado