How to make the
<?php
echo @$str_ano, @$str_mes, @$str_dia,
@$str_hora, @$str_min, @$str_seg,' atrás';
?>
Understand and print only the ID data specific to each line and do not print multiple times as the example below
ID 01 --> 2 min
ID 02 --> 2 min 2 min
ID 03 --> 2 min 2 min 2 min
From what I understand is lack of something in this echo because when I take the part that specifies the ID in SELECT it works normal. HELP ME!
Summing up:
What am I doing? It's a list of users that start a new session, in this listing that part of the code calls the last login time, in suna, what I need then is to make each ID in this listing receive the result for its last login time.
Here the 'complete' code to understand better, the echo is in the end.
<?php
$resul_ult_aces = "SELECT DATE_FORMAT(data_acesso, '%Y-%m-%d-%H-%i-%s') as
data_acesso FROM adms_ultimos_acessos
WHERE adms_usuario_id = '".$row_user['id']."'
ORDER BY id DESC LIMIT 1";
$resultado_ult_aces = mysqli_query($conn, $resul_ult_aces);
$row_ult_aces = mysqli_fetch_assoc($resultado_ult_aces);
<?php
$ob_data_acesso = $row_ult_aces ['data_acesso'];
$databd2 = date('Y-m-d-H-i-s');
$data1 = explode('-', $ob_data_acesso);
$data2 = explode('-', $databd2);
$ano = $data2[0] - $data1[0];
$mes = $data2[1] - $data1[1];
$dia = $data2[2] - $data1[2];
$hora = $data2[3] - $data1[3];
$min = $data2[4] - $data1[4];
$seg = $data2[5] - $data1[5];
// configuração data
if ($mes < 0) {$ano--; $mes = 12 + $mes; }
if ($dia < 0) { $mes--; $dia = 30 + $dia; }
if ($ano > 0) { $str_ano = $ano . ' ano'; }
if ($ano > 1) { $str_ano .= 's '; }
if ($mes > 0) { @$str_mes .= $mes . ' mes'; }
if ($mes > 1) {
if ($ano > 0) { $str_ano .= ', '; } $str_mes .= 'es'; }
if ($dia > 0) { $str_dia = $dia . ' dia'; }
if ($dia > 1) {
if ($mes > 0) { $str_mes .= ', '; } $str_dia .= 's'; }
// configuração hora
if ($min < 0) {$hora--; $min = 60 + $min; }
if ($seg < 0) { $min--; $seg = 60 + $seg; }
if ($hora > 0) { $str_hora = $hora . ' hora'; }
if ($hora > 1) { @$str_hora .= 's'; }
if ($min > 0) { @$str_min .= $min . ' minuto'; }
if ($min > 1) {
if ($hora > 0) { @$str_hora .= ', '; } @$str_min .= 's'; }
if ($seg > 0) { $str_seg = $seg . ' seg'; }
if ($seg > 1) {
if ($min > 0) { $str_min .= ' e '; } $str_seg .= 's'; }
<td class="d-none d-sm-table-cell">
<?php //echo $row_ult_aces['data_acesso'];
echo @$str_ano, @$str_mes, @$str_dia,
@$str_hora, @$str_min, @$str_seg,' atrás';
?>
</td>