duanjiaolia97750 2015-08-19 08:01
浏览 20
已采纳

手动获取列数据

I am working on a project in which I have a table with 4 columns. I want to get the last non-empty data of the every column, such as It will show

  • column1 + its last non-empty data
  • column2 + its last non-empty data
  • column3 + its last non-empty data
  • column4 + its last non-empty data

So can you explain me which code is applied to do that

enter image description here

  • 写回答

2条回答 默认 最新

  • duanlinzhen7235 2015-08-19 14:03
    关注

    I get it statically but is there any way for dynamically and use just only one array instead of $a, $b, $c

            while ($row = mysqli_fetch_array($result)) 
        {  
        if($row['name']!='' && $row['password']=='' && $row['username']=='' )
        {
            $a['name']=$row['name'];
            $a['username']=$row['username'];
            $a['password']=$row['password'];
        }
        if($row['name']=='' && $row['username']!='' && $row['password']=='')
        {
            $b['name']=$row['name'];
            $b['username']=$row['username'];
            $b['password']=$row['password'];            
        }
        if($row['name']=='' && $row['username']=='' && $row['password']!='')
        {
            $c['name']=$row['name'];
            $c['username']=$row['username'];
            $c['password']=$row['password'];
        }
    }
    
        echo "<tr>";
        echo '<td>'.$a['name'].'</td>';
        echo '<td>'.$a['username'].'</td>';
        echo '<td>'.$a['password'].'</td>';
        echo "</tr>";
    
        echo "<tr>";
        echo '<td>'.$b['name'].'</td>';
        echo '<td>'.$b['username'].'</td>';
        echo '<td>'.$b['password'].'</td>';
        echo "</tr>";
    
        echo "<tr>";
        echo '<td>'.$c['name'].'</td>';
        echo '<td>'.$c['username'].'</td>';
        echo '<td>'.$c['password'].'</td>';
        echo "</tr>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码
  • ¥15 AutoDL无法使用docker install吗?
  • ¥15 cups交叉编译后移植到tina sdk的t113,只需要实现usb驱动打印机,打印pdf文件
  • ¥30 关于#wireshark#的问题:需要网络应用流量数据集需要做长度序列的实验,需要与应用产生的会话的数据包的长度,如视频类或者聊天类软件
  • ¥15 根据上述描述表示泥浆密度沿着管路的长度方向在不断变化,如何来表示泥浆密度随管路的变化(标签-matlab|关键词-流计算)
  • ¥21 matlab可以把图像数据转换为小波分析吗
  • ¥60 基于香农编码的图像压缩算法实现
  • ¥15 matlabGUI绘制一个函数与其导数的图像
  • ¥20 大数据采集用Python爬取猫眼电影数据