Generate report via php

report

I want to get the report like this from my database tables. Things should consider when making the report are :

  1. report will generate based on the selected date.
  2. two database and two tables ( already joined ) 'showroom' and 'customer'
  3. showroom have showroom_name and each have related records in customer
    table. One showroom may have several customer enquiry in each days.
  4. In a single day may have number of enquiry from each showroom.
  5. Let's say if the first day of a month 5 enquiries it should be appear under the date column and in front of the specific showroom name.

my query to select the data from two tables are works fine.

SELECT abans_crm.customers.added_date, abans_crm.customers.location_id FROM abans_crm.customers INNER JOIN sh_sso.showrooms ON sh_sso.showrooms.showroom_id = abans_crm.customers.location_id WHERE abans_crm.customers.added_location = -99 AND abans_crm.customers.type_id = 1 ORDER BY abans_crm.customers.location_id ASC 

Query result is

query result

Which i was marked two data have two different dates. 2016-02-09 and 2016-02-23. '356' is the showroom_id so day 9 column of the report become 1 and day 23 column become 1. hope you get my point. How could i count each showroom number of enquiry ?

Hers the code snippet which i have write so far. don't know to write afterwards

showroom_name; $conn = mysql_connect('localhost', 'root', 'Sate11it@') or die("Unable to connect to MySQL"); mysql_select_db('sh_sso', $conn); mysql_select_db('abans_crm', $conn); $query_3 = "SELECT abans_crm.customers.added_date, abans_crm.customers.location_id FROM abans_crm.customers INNER JOIN sh_sso.showrooms ON sh_sso.showrooms.showroom_id = abans_crm.customers.location_id WHERE abans_crm.customers.added_location = -99 AND abans_crm.customers.type_id = 1 ORDER BY abans_crm.customers.location_id ASC"; $retval = mysql_query($query_3); if(!$retval ) < die('Could not get data: ' . mysql_error()); >$select_month = '2'; $select_year = '2016'; $days = cal_days_in_month(CAL_GREGORIAN,$select_month,$select_year); while ($row2 = mysql_fetch_assoc($retval)) < $year = date('Y',strtotime($row2['added_date'])); $month = date('m',strtotime($row2['added_date'])); $date = date('m',strtotime($row2['added_date'])); $showroom_id = $row2['location_id']; if($year == $select_year && $month == $select_month)< for($a = 1; $a > > ?> 

if you need more details please comment below.

customer table fields cu_id , cu_name , cu_email , cu_address , cu_phone , cu_remark , added_date , last_update , added_by , status_id , location_id , cu_nic , cu_age , cu_occ , cu_land , purchase_type , pref_model , pref_color , oth_model , purchase_date , currenrt_bike , bike_year , att_by , cu_made , about_hero , source_id , added_ip , dealer_flag , added_location , cur_milage , cat_id , type_id

showroom table fields showroom_id , showroom_code , showroom_name , showroom_address , address_city , manager_name , manager_mobile , manager_id , shop_email , shop_phone , shop_fax , showroom_type , added_date , last_update , added_by , status_id , level_id