Thanks in advance, I am new to cakephp, i am using cakephp2.8.5 version. Actually i want to write a php code for counting number of records from the mysql database table comparing the ordered date column date values with the current date. I have written the code but my menus are in default.ctp page. In Order Check menu i have to show the count in numbers. default.ctp page lying in app/view/Layout/default.ctp so how to create a count value in php code without using controller.
My code will compare the current date with the table column date and calculates the count.How can i pass the variable $ordCounts into default.ctp page without creating controller page Which is as below:
<?php
$a = 0;
for($j=0; $j<count($ordCounts) ;$j++)
{
$orderDate = $ordCounts[$j]['carts']['order_date'];
$currentDate = $dateTime;
$diff = strtotime($currentDate) - strtotime($orderDate);
$hour = $diff/(60*60);
if($hour>24)
{
$a++;
}
}
echo $a;
?>