如何在php codeigniter ..中的单列中显示数据库中插入记录的插入日期相同?

时间:2018-12-03 07:38:59

标签: php ajax codeigniter

这是我的表table_old_memerization,我从视图页面插入了我的数据。他的表有114章。每个学生需要完成114章。如果今天有一位学生完成了10章,那么我想就今天的日期将所有记录显示在一行中。如果明天同一位学生完成了5章,那么我想在第二栏中显示5条关于日期的记录。

这是我的模型查询:

core.events.all()

我的带有记录的数据库结构:-

enter image description here

如何在数据库的查看页面中显示记录

enter image description here

目前,像这样显示: enter image description here

1 个答案:

答案 0 :(得分:0)

在记录日期使用分组依据获取分组记录。

SELECT table1.*
FROM table_old_memerization AS table1
JOIN (SELECT table2.primary_key,table2.date_time
      FROM table_old_memerization
      GROUP BY date(table2.date_time)
      AS table2
ON table1.primary_key = table2.primary_key

使用一些日期解析方法来转换日期格式。

date("d-m-Y", strtotime($yourDateVariable));

$date = new DateTime($yourDateVariable);
echo $date->format('d-m-Y'); // 03-12-2018