I should be write report page with php.this report include one table that get information from database. my structure like that:
technician_id psp_id percent pm_date
------------- ------- -------- --------
8 16 50 13940415
10 16 40 13940416
12 16 60 13940417
I want show table like :
technician_name 13940415 13940416 13940417
-------------- -------- -------- ---------
ali 16 00 00
abbas 00 40 00
ahmad 00 00 60
I need help soon.thanks
my code:
echo "<table border='1'>";
echo"<tr>";
echo"<td></td>";
$date_value = mysql_query("select pmcontrol.* from pmcontrol")or die(mysql_error());
$count=mysql_num_rows($date_value);
while($rows=mysql_fetch_array($date_value)){
$arr = array();
echo"<td>".$rows['pmdate']."</td>";
for($k=0;$k<31 ;$k++){
$arr[$k]=$rows['pmdate'];
}
}
echo"</tr>";
$search=mysql_query("select pmcontrol.*,user.*
from pmcontrol
INNER JOIN user
on user.u_id=pmcontrol.technician_id
INNER JOIN psp
on psp.id=pmcontrol.psp_id
where pmcontrol.pmdate between $from_date and $until_date
group by technician_id
") or die(mysql_error());
$count=mysql_num_rows($search);
while($row=mysql_fetch_array($search)){
echo"<tr>";
echo"<td>".$row['user_name']." ".$row['user_family']."</td>";
for($k=0;$k<2;$k++){
if($row['pmdate']=$arr[$k]){
echo"<td>".$row['percent']."</td>";
}
else if($row['pmdate']!=$arr[$k]) {
echo"<td>00</td>";
}}
echo"</tr>";
}
echo "</table>";
my result :
technician_name 13940415 13940416 13940417
--------------- -------- -------- --------
ali 16 16 16
abbas 40 40 40
ahmad 60 60 60