如何从 php codeigniter 中的给定日期选择完整的月份
我有一个CodeIgniter网站,我试图根据用户ID和日期显示一些结果,
我的数据库如下:
我有一个类似的日期,用户将选择:2022-04-08
我想要的是从该完整月份的表中获取所有数据,如果我得到一个日期,我想提取完整的月份。
我做了这样的事情:
public function selectview($id,$date)
{
$this->db->select('*');
$this->db->from('delivered');
$this->db->where("cid", $id);
$this->db->like('date', $date, 'after');
$query = $this->db->get();
$result = $query->result();
return $result;
}
但是,这并没有给那个月的所有日期,任何人都可以告诉我如何实现这一目标,谢谢
i have a codeigniter website where i am trying to display some results based on user id and date,
my database is like below:
i have a single date like this which will be selected by user: 2022-04-08
what i want is to get all the data from table of that complete month, if i get a single day date i want to fetch the complete month.
i did something like this:
public function selectview($id,$date)
{
$this->db->select('*');
$this->db->from('delivered');
$this->db->where("cid", $id);
$this->db->like('date', $date, 'after');
$query = $this->db->get();
$result = $query->result();
return $result;
}
however this doesnt give all the dates of that month, can anyone please tell me how to accomplish this, thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
$ date
修改为Year
和月
。尝试这样的事情:You need to modify
$date
to justyear
andmonth
. try something like this :