【问题标题】:How do I display mysql data in row span using Codeigniter?如何使用 Codeigniter 在行跨度中显示 mysql 数据?
【发布时间】:2014-07-19 16:12:14
【问题描述】:

如何使用 Codeigniter 在行跨度中显示 mysql 数据?我尝试了更多次但不能!我可以显示 MySql 数据库中的所有数据,但是当我尝试在行跨度中显示数据时失败了!

这是屏幕截图。你会清楚我需要什么:

http://prntscr.com/42t7ul

请帮帮我!

谢谢

【问题讨论】:

  • 请分享你对应的代码..
  • 看起来你想做rowspan之类的事情。如果您在返回数据库行的同时构建表行并且不知道您的rowspan,那么您可以使用类似$currDate = ''; yourWhileLoop($row = ....) { if($row['date'] != $currDate) { echo $row['date']; $currDate = $row['date']; } ... rest of your loop }

标签: php mysql sql codeigniter


【解决方案1】:

如果你在 Codeigniter 中使用视图,那么你可以这样使用它:

foreach ($array_data as $date => $recs)
{
    $one_recs_cnt = count($recs);
    echo "<tr><td rowspan=" . $one_recs_cnt . ">" . $sno++ . "</td><td rowspan=" . $one_recs_cnt . ">" . $date . "</td>";
    foreach ($recs as $key => $data)
    {
        echo "<td>" . $data['category'] . "</td><td>" . $data['description'] . "</td><td>" . $data['author'] . "</td></tr>";
    }
}

如果您的数组值如下所示:

Array ( [15-07-2014] => 
    Array (
            [0] => 
                Array ( [category] => Default1 [description] => xy [author] => A1 )
            [1] => 
                Array ( [category] => Default1 [description] => yz [author] => A2 )
            [2] => 
                Array ( [category] => Default1 [description] => xz [author] => A3 )
                )
            )
    )

【讨论】:

    猜你喜欢
    • 2010-09-18
    • 1970-01-01
    • 2019-01-25
    • 2019-06-25
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    相关资源
    最近更新 更多