Skip to main content

coding for the rate calculation of dcs

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

Popular posts from this blog

Creating designed pages in tkinter

Here in this blog we can make the creative pages in tkinter for the entry section   So here are the following codes for that:- from tkinter import * user_form = Tk () user_form . geometry ( "750x450" ) user_form . title ( "Register form" ) user_form . resizable ( 0 , 0 ) pic1 = PhotoImage ( file = "user_form.png" ) user_form1 = Label ( user_form , image = pic1 , width = 750 , height = 450 ) user_form1 .image= pic1 user_form1 . pack () name_en = Entry ( user_form , width = 14 , relief = "flat" , font =( "times" , 20 )) name_en . place ( relx = 0.385 , rely = 0.265 ) user_en = Entry ( user_form , width = 19 , relief = "flat" , font =( "times" , 20 )) user_en . place ( relx = 0.385 , rely = 0.365 ) psswd_en = Entry ( user_form , width = 18 , relief = "flat" , font =( "times" , 20 )) psswd_en . place ( relx = 0.385 , rely = 0.485 ) pic3 = PhotoImage ( file = "register.png" ) but1 = Button...

entry box with the automatic listbox

 Here in this coding we are going to show the entry connected with the listbox in python. so here is the following coding as respective to the needs. ========================================================================= import tkinter as tk def on_change (* args ):     # print(args)     value = var_text . get ()     value = value . strip (). lower ()     # get data from test_list     if value == '' :         data = test_list     else :         data = []         for item in test_list :             if value in item . lower ():                 data . append ( item )                 # update data in listbox     listbox_update ( data ) def listbox_update ( data ):     # delete previous data     listbox . delete...

How to make form in HTML?

  Here in this blog, we are providing the programming codes for making an HTML form. so here are the following codes:- <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < title > forms </ title > </ head > < body >     < h2 > this is form tutorial </ h2 >     < form action = "backend.php" >         <!-- yaha par bas input type karo aur ek list dikhayga aur jo daalna           hai select kar lo -->       <!-- here label works that if label for="name" and id ="name" than if we           will click on name on html web page than the cursor will go on the  ...