dongle2627 2019-02-27 05:54
浏览 45

从echo中的特定ID获取数据(错误!)

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题