Welcome Guest, Not a member yet? Register   Sign In
Show results based on a specific date
#1

Hello, I would like to show the results from the database only inserted in a specific time frame. I would therefore like to show only the results that have been inserted by the date (example: 20 March 2018).

This is an example of proof, with other restrictions such as the most voted.

PHP Code:
public function test($limit=null$offset=null) {
 
       $this->db->select('*');
 
       $this->db->from('test');
 
       $this->db->where('status'1); // where status is 1 (active)
 
       $this->db->order_by('likes''DESC');
 
       $this->db->limit($limit);
 
       $this->db->offset($offset);
 
       $query $this->db->get();
 
       return $query->result_array();
 
   
Reply
#2

(This post was last modified: 03-14-2018, 08:16 AM by php_rocs.)

@Marcolino92,

You should have an addition to the where clause. This addition should be where you check that the date is equal to a specific date.

example:
Select * from test where status = 1 and record_date = '2018-03-20'
Reply
#3

Hello, thank you for your help. Could you recommend me how to create a two-date range?
Reply
#4

PHP Code:
$this->db->where('date >=',$from);
$this->db->where('date <=',$to); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB