I am trying to make a project wherein it display the 3 previous monnth and the current month.. now my problem is I dont know where or how to reflect this mysql data into a table in php... can anyone taught me please?
Pardon me if I'm not good in explaining to you the system because I'm just a trying hard programmer..
this should be how the table will look like: http://www.fileden.com/files/2011/7/27/3174077//1.JPG
here is the php codes and mysql query that i want to put into a table:
<form action="" method="post" class="niceform">
<fieldset>
<legend>Job Orders</legend>\
<table>
<tr>
<th>SSA</th>
<th>Months</th>
</tr>
<?php
$datefrom= $_POST['timestamp'];
$dateto=$_POST['timestamp1'];
$parsemonth="";
$parseday ="01";
$conditionmonth=$parsemonth-3;
//january
if ($conditionmonth == '1'){
$sql="SELECT
a.specialist_partner_ID
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-01-01', INTERVAL 3 MONTH) and DATE_SUB('2011-09-30', INTERVAL 3 MONTH) THEN a.job_order_number ELSE null END) As December,
count(CASE WHEN a.receivedDate between DATE_SUB('2011-01-01', INTERVAL 2 MONTH) and DATE_SUB('2011-09-30', INTERVAL 2 MONTH) THEN a.job_order_number ELSE null END) As November
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-01-01', INTERVAL 1 MONTH) and DATE_SUB('2011-09-30', INTERVAL 1 MONTH) THEN a.job_order_number ELSE null END) As October
,count(CASE WHEN a.receivedDate between '2011-01-01' and '2011-01-30'THEN a.job_order_number ELSE null END) As Jauary
,count(job_order_number) As Total
FROM jo_partner a
WHERE a.receivedDate BETWEEN '2011-01-01' AND '2011-12-31'
GROUP BY a.specialist_partner_ID";
}
//february
else if ($conditionmonth == '2'){
$sql="SELECT
a.specialist_partner_ID
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-02-01', INTERVAL 11 MONTH) and DATE_SUB('2011-02-29', INTERVAL 3 MONTH) THEN a.job_order_number ELSE null END) As November
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-02-01', INTERVAL 10 MONTH) and DATE_SUB('2011-02-29', INTERVAL 2 MONTH) THEN a.job_order_number ELSE null END) As December
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-02-01', INTERVAL 9 MONTH) and DATE_SUB('2011-02-29', INTERVAL 1 MONTH) THEN a.job_order_number ELSE null END) As January
,count(CASE WHEN a.receivedDate between '2011-02-01' and '2011-02-29'THEN a.job_order_number ELSE null END) As February
,count(job_order_number) As Total
FROM jo_partner a
WHERE a.receivedDate BETWEEN '2011-01-01' AND '2011-12-31'
GROUP BY a.specialist_partner_ID";
}
//march
else if ($conditionmonth == '3')
{
$sql="SELECT
a.specialist_partner_ID
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-03-01', INTERVAL 3 MONTH) and DATE_SUB('2011-03-31', INTERVAL 3 MONTH) THEN a.job_order_number ELSE null END) As December
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-03-01', INTERVAL 2 MONTH) and DATE_SUB('2011-03-31', INTERVAL 2 MONTH) THEN a.job_order_number ELSE null END) As Jauary
,count(CASE WHEN a.receivedDate between DATE_SUB('2011-03-01', INTERVAL 1 MONTH) and DATE_SUB('2011-03-31', INTERVAL 1 MONTH) THEN a.job_order_number ELSE null END) As February
,count(CASE WHEN a.receivedDate between '2011-03-01' and '2011-03-31'THEN a.job_order_number ELSE null END) As March
,count(job_order_number) As Total
FROM jo_partner a
WHERE a.receivedDate BETWEEN '2011-01-01' AND '2011-12-31'
GROUP BY a.specialist_partner_ID";
}
and so on and so forth... up to DECEMBER
while ($row = mysql_fetch_row($sql)
{
}
?>
</tr></table>
</fieldset>
the condition is when I select a month to view the report for that month, ex January, only data from January will only be visible and the last 3 consrctive month, ex december and november