| Direktori : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/fertilizer/ |
| Current File : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/fertilizer/newhtml.html |
<!DOCTYPE html>
<table id="datatables" class="table table-hover">
<thead class="text-success">
<th class="text-center">สูตรปุ๋ยที่ผสม</th>
<th class="text-center">จำนวนที่ผสม(เป็นกระสอบ)</th>
<th class="text-center">แม่ปุ๋ย</th>
<!-- <th class="text-center">แม่ปุ๋ย46-0-0</th>
<th class="text-center">แม่ปุ๋ย18-46-0</th>
<th class="text-center">แม่ปุ๋ย0-0-60</th> -->
<th class="text-center">รวมทั้งสิ้น(กิโลกรัม)</th>
</thead>
<tbody>
<?php
$sum_sack = 0;
$sack46 = 0;
$sack18 = 0;
$sack0 = 0;
$sum1 = 0;
$sum2 = 0;
$sum3 = 0;
$sum_sum = 0;
while ($row_report1 = mysqli_fetch_array($result_report1)) { ?>
<tr>
<td class="text-center"><?php echo $row_report1['name_formula']; ?></td>
<td class="text-center"><?php echo $row_report1['sack']; ?></td>
<td class="text-center"><?php echo $row_report1['S_mother_pui']; ?></td>
<!-- <td class="text-center"><?php echo $row_report1['fm18-46-0']; ?></td>
<td class="text-center"><?php echo $row_report1['fm0-0-60']; ?></td> -->
<td class="text-center"><?php echo $row_report1['sum']; ?></td>
</tr>
<?php
$sum_sack = $sum_sack+$row_report1['sack'];
// $sum46 = $row_report1['S_mother_pui'];
if ($row_report1['S_mother_pui'] == '46-0-0') {
$sum1 = $sum1 + $row_report1['sum'];
$sack46 = $sack46 + $row_report1['sack'];
}elseif ($row_report1['S_mother_pui'] == '18-46-0') {
$sum2 = $sum2 + $row_report1['sum'];
$sack18 = $sack18 + $row_report1['sack'];
}elseif ($row_report1['S_mother_pui'] == '0-0-60') {
$sum3 = $sum3 + $row_report1['sum'];
$sack0 = $sack0 + $row_report1['sack'];
}
$sum_sum = $sum_sum+$row_report1['sum'];
?>
<?php } ?>
<tr>
<td class="text-center">ผลรวม</td>
<td class="text-center"> <?php echo $sum_sack; ?> </td>
<td class="text-center"> <?php ?> </td>
<!-- <td class="text-center"> <?php echo $sum_fm18; ?> </td>
<td class="text-center"> <?php echo $sum_fm0; ?> </td> -->
<td class="text-center"> <?php echo $sum_sum; ?> </td>
</tr>
</tbody>
</table>
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "1234";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT DISTINCT fl.name_formula as'สูตร',t1.sack as'กระสอบ', t2.sum as'46-0-0',t3.sum as'18-46-0',t4.sum as'0-0-60'
FROM sahakorn AS sk
INNER JOIN sahakorn_process AS t1 ON t1.sahakornID=sk.sahakornID
INNER JOIN sahakorn_process AS t2 ON t2.S_mother_pui='46-0-0' AND t2.sahakornID=sk.sahakornID AND t1.sack=t2.sack AND t1.formulaID=t2.formulaID AND t1.`year`=t2.`year`
INNER JOIN sahakorn_process AS t3 ON t3.S_mother_pui='18-46-0' AND t3.sahakornID=sk.sahakornID AND t2.sack=t3.sack AND t2.formulaID=t3.formulaID AND t2.`year`=t3.`year`
INNER JOIN sahakorn_process AS t4 ON t4.S_mother_pui='0-0-60' AND t4.sahakornID=sk.sahakornID AND t3.sack=t4.sack AND t3.formulaID=t4.formulaID AND t3.`year`=t4.`year`
INNER JOIN formula AS fl ON fl.formulaID=t1.formulaID WHERE t1.sahakornID=5
";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<br> สูตร ". $row["สูตร"].
"<br> จำนวน ". $row["กระสอบ"]
;
}
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>