I want done where date now with dates that there are in database table as JSON in offset 2 (like: 2011/10/30
= date now
and Etc.
), in my try output num rows is 0
. how can done it?
My column in table:
$today = date("Y/m/d"); // This is 2011/10/30
$query = $this->db->query("SELECT * FROM table WHERE new_date LIKE $today");
echo $query->num_rows(); // This output is "0"
Try
$query = $this->db->query("SELECT * FROM table WHERE new_date LIKE '".$today."'");
Try this:
$today = date("Y/m/d"); // This is 2011/10/30
$today = str_replace("/",'\/',$today); // match your db format in json
$sql = "SELECT * FROM `table` WHERE `new_date` LIKE '%$today%'";
echo $sql.'<br />'; // Copy this line below so we can see your output
$query = $this->db->query("SELECT * FROM `table` WHERE `new_date` LIKE '%$today%'");
echo $query->num_rows();
Following from the comments above.