how to convert mysql query to php query? : SET @sql = NULL;
		SELECT
		  GROUP_CONCAT(DISTINCT
			CONCAT(
			  'max(CASE WHEN ca.date = ''',
			  date_format(date, '%Y-%m-%d'),
			  ''' THEN coalesce(p.status, ''P'') END) AS `',
			  date_format(date, '%Y-%m-%d'), '`'
			)
		  ) INTO @sql
		FROM calendar
		where date>='2013-06-01'
		  and date <= '2013-06-05';

		SET @sql 
		  = CONCAT('SELECT ca.studentname,
					  ca.rollno,
					  ca.class, ', @sql, ' 
					from
					(
					  select c.date, a.studentname, a.rollno, a.class
					  from calendar c
					  cross join tbl_admission a
					) ca
					left join tbl_absentees p
					  on ca.rollno = p.rollno
					  and ca.date = p.date
					where ca.date>=''2013-06-01''
					  and ca.date <= ''2013-06-05''
					group by ca.studentname, ca.rollno, ca.class
					order by ca.rollno');

		PREPARE stmt FROM @sql;
		EXECUTE stmt;
		DEALLOCATE PREPARE stmt;