01.
<?php
02.
03.
$sql1
=
"SELECT * FROM batch_detail where sc_id='"
.
$_GET
[
"sc_id"
].
"' and id='"
.
$_GET
[
"id"
].
"' GROUP BY product_name"
;
04.
$query1
= mysqli_query(
$conn
,
$sql1
);
05.
while
(
$result1
=mysqli_fetch_array(
$query1
))
06.
{
07.
$id
[]=
$result1
[
"b_id"
];
08.
$name
[]=
$result1
[
"product_name"
];
09.
$pd_id
[]=
$result1
[
"pd_id"
];
10.
$sum
[] =
$result1
[
"mrp"
];
11.
12.
}
13.
14.
$sql2
=
"SELECT * FROM batch_detail where sc_id='"
.
$_GET
[
"sc_id"
].
"' and id='"
.
$_GET
[
"id"
].
"' GROUP BY date "
;
15.
$query2
= mysqli_query(
$conn
,
$sql2
);
16.
while
(
$result2
=mysqli_fetch_array(
$query2
))
17.
{
18.
$bdate
[]=
$result2
[
"date"
];
19.
}
20.
?>
21.
22.
<table width=
"100%"
border=
"1"
cellpadding=
"0"
cellspacing=
"0"
>
23.
<thead>
24.
<tr>
25.
<th height=
"30"
style=
" text-align: center; background-color: #cccccc;"
>Item</th>
26.
<?php
for
(
$i
=0;
$i
<
count
(
$bdate
);
$i
++){ ?>
27.
<th
class
=
"text-center"
width=
"10%"
style=
"background-color: #cccccc"
><?php
echo
date
(
'd/m/Y'
,
strtotime
(
$bdate
[
$i
])); ?></th>
28.
<?php } ?>
29.
<th width=
"5%"
class
=
"text-center"
style=
"background-color: #cccccc"
>MRP</th>
30.
</tr>
31.
</thead>
32.
<tbody>
33.
<?php
34.
for
(
$i
=0;
$i
<
count
(
$name
);
$i
++){
35.
?>
36.
<tr>
37.
<td height=
"30"
> <b><?php
echo
$pd_id
[
$i
]; ?> <?php
echo
$name
[
$i
]; ?></b></td>
38.
39.
40.
<?php
for
(
$j
=0;
$j
<
count
(
$bdate
);
$j
++){
41.
42.
$sql3
=
"SELECT * FROM batch_detail WHERE `date`= '$bdate[$j]' AND `product_name` = '$name[$i]' AND sc_id='"
.
$_GET
[
"sc_id"
].
"' AND id='"
.
$_GET
[
"id"
].
"'"
;
43.
$query3
= mysqli_query(
$conn
,
$sql3
);
44.
$result3
= mysqli_fetch_array(
$query3
) ?>
45.
<td height=
"30"
style=
" text-align: center;"
>
46.
<b><?php
if
(
$result3
[
'mrp'
] == 0){
47.
48.
echo
""
;
49.
50.
}
else
{
51.
52.
echo
number_format(
$result3
[
'mrp'
]); }?></b>
53.
</td>
54.
55.
<?php } ?>
56.
57.
<td height=
"30"
width=
"10%"
style=
" text-align: center; "
>
58.
<?php
59.
$sum
=0;
60.
61.
$sum
=
$sum
+
$result3
[
"mrp"
] ;
62.
echo
$sum
;
63.
64.
?>
65.
</td>
66.
</tr>
67.
<?php } ?>
68.
69.
</tbody>
70.
</table>