if ($_GET['updatekg']==0) {
$query = "SELECT * FROM `samudra` WHERE `date`='$_GET[date]' AND `status`='0' ";
$res = mysqli_query($con, $query);
while ($row = mysqli_fetch_assoc($res)) {
$fatkg = ($row['fat'] * $row['qty']) / 100;
$snfkg = ($row['snf'] * $row['qty']) / 100;
if (3 <= $row['fat'] && $row['fat'] <= 5.4 ) {
$queryrate = "SELECT * FROM `rate0` WHERE `fat`='$row[fat]' AND `snf`='$row[snf]'";
$resrate = mysqli_query($con, $queryrate);
if (mysqli_num_rows($resrate) != 0) {
$rowrate = mysqli_fetch_assoc($resrate);
$rate = $row['qty'] * $rowrate['rate'];
$price=$rowrate['rate'];
} else {
if( $row['fat'] < 3.0 || $row['snf'] < 8.0){
$rate="0.0";
$price=0;
}
elseif(3 <= $row['fat'] && $row['fat'] <= 5.4 && 8.5 <= $row['snf']){
$queryrate0 = "SELECT * FROM `rate0` WHERE `fat`='$row[fat]' AND `snf`='8.5'";
$resrate0 = mysqli_query($con, $queryrate0);
$rowrate0 = mysqli_fetch_assoc($resrate0);
$rate = $row['qty'] * $rowrate0['rate'];
$price=$rowrate0['rate'];
}
}
}
elseif (5.5 <= $row['fat'] && $row['fat'] <= 7.9 ) {
$queryrate = "SELECT * FROM `rate1` WHERE `fat`='$row[fat]' AND `snf`='$row[snf]'";
$resrate = mysqli_query($con, $queryrate);
if (mysqli_num_rows($resrate) != 0) {
$rowrate = mysqli_fetch_assoc($resrate);
$rate = $row['qty'] * $rowrate['rate'];
$price=$rowrate['rate'];
} else {
if( $row['snf'] <= 8.4){
$rate="0.0";
$price=0;
}
elseif(5.5 <= $row['fat'] && $row['fat'] <= 5.9 && 8.8 < $row['snf']){
$queryrate0 = "SELECT * FROM `rate1` WHERE `fat`='$row[fat]' AND `snf`='8.8'";
$resrate0 = mysqli_query($con, $queryrate0);
$rowrate0 = mysqli_fetch_assoc($resrate0);
$rate = $row['qty'] * $rowrate0['rate'];
$price=$rowrate0['rate'];
}
elseif( 9.0 < $row['snf']){
$queryrate0 = "SELECT * FROM `rate1` WHERE `fat`='$row[fat]' AND `snf`='9.0'";
$resrate0 = mysqli_query($con, $queryrate0);
$rowrate0 = mysqli_fetch_assoc($resrate0);
$rate = $row['qty'] * $rowrate0['rate'];
$price=$rowrate0['rate'];
}
}
}
elseif (8.0 <= $row['fat'] && $row['fat'] <= 10.0 ) {
$queryrate = "SELECT * FROM `rate2` WHERE `fat`='$row[fat]' AND `snf`='$row[snf]'";
$resrate = mysqli_query($con, $queryrate);
if (mysqli_num_rows($resrate) != 0) {
$rowrate = mysqli_fetch_assoc($resrate);
$rate = $row['qty'] * $rowrate['rate'];
$price=$rowrate['rate'];
} else {
if( $row['snf'] <= 8.4){
$rate="0.0";
$price=0;
}
elseif( 9.0 <= $row['snf']){
$queryrate0 = "SELECT * FROM `rate2` WHERE `fat`='$row[fat]' AND `snf`='9.0'";
$resrate0 = mysqli_query($con, $queryrate0);
$rowrate0 = mysqli_fetch_assoc($resrate0);
$rate = $row['qty'] * $rowrate0['rate'];
$price=$rowrate0['rate'];
}
}
}
$updatewa = "UPDATE `samudra` SET `fatkg`='$fatkg',`snfkg`='$snfkg',`rate`='$rate',`perprice`='$price',`status`='1' WHERE `id`='$row[id]'";
mysqli_query($con, $updatewa);
}
echo "<script>window.location.href='index.php'</script>";
}
Comments
Post a Comment