Skip to main content

upload.php for the app for uploading the excel sheet in kdp data of samudra

<?php

include("../header.php");

require("connect.php");


if (isset($_POST['samudra'])) {

    $file = $_FILES['doc']['tmp_name'];


    $ext = pathinfo($_FILES['doc']['name'], PATHINFO_EXTENSION);

    if ($ext == 'xlsx' or 'XLSX') {

        require('PHPExcel/PHPExcel.php');

        require('PHPExcel/PHPExcel/IOFactory.php');



        $obj = PHPExcel_IOFactory::load($file);

        foreach ($obj->getWorksheetIterator() as $sheet) {

            $getHighestRow = $sheet->getHighestRow();

            for ($i = 0; $i <= $getHighestRow; $i++) {

                $bmc = $sheet->getCellByColumnAndRow(0, $i)->getValue();

                $route = $sheet->getCellByColumnAndRow(1, $i)->getValue();

                $society = $sheet->getCellByColumnAndRow(2, $i)->getValue();

                $date = $sheet->getCellByColumnAndRow(3, $i)->getValue();

                $shift = $sheet->getCellByColumnAndRow(4, $i)->getValue();

                $sample = $sheet->getCellByColumnAndRow(5, $i)->getValue();

                $cate = $sheet->getCellByColumnAndRow(6, $i)->getValue();

                $type = $sheet->getCellByColumnAndRow(7, $i)->getValue();

                $qty = $sheet->getCellByColumnAndRow(8, $i)->getValue();

                $fat0 = $sheet->getCellByColumnAndRow(9, $i)->getValue();

                $snf0 = $sheet->getCellByColumnAndRow(10, $i)->getValue();

                $lr = $sheet->getCellByColumnAndRow(11, $i)->getValue();

                $rcan = $sheet->getCellByColumnAndRow(12, $i)->getValue();

                $acan = $sheet->getCellByColumnAndRow(13, $i)->getValue();

                $bmc0 = substr($bmc, 1);

                $bmc1 = strtok($bmc0, ']'); //yaha 1801 bmc number aayega

                $route0 = substr($route, 1);

                $route1 = strtok($route0, ']'); //yaha route code aayega

                $route2 = strstr($route, ' '); //yaha route name aayega

                $society0 = substr($society, 1);

                $society1 = strtok($society0, ']'); //yaha society code milega 

                $society2 = strstr($society, ' '); //yaha society name milega

                $date0 = str_replace("/", "-", $date);

                $date1 = date("Y-m-d", strtotime($date0));//yaha date aayega

                $fat=number_format((float)$fat0, 1, '.', '');

                $snf=number_format((float)$snf0, 1, '.', ''); 

                if ($date != '') {

                    $query="INSERT INTO `samudra`(`bmccode`, `routecode`, `routename`, `societycode`, `societyname`, `date`, `shift`, `sampleno`, `qty`, `fat`, `snf`, `grade`,`cate`,`acan`, `status`) VALUES ('$bmc1','$route1','$route2','$society1','$society2','$date1','$shift','$sample','$qty','$fat','$snf','$type','$cate','$acan','0')";

                    mysqli_query($con,$query);

                }

                elseif ($date == ''){

                    echo "<script>alert('Details added successfully');

                 window.location.href='upload.php'</script>";

                }


                

            }

        }

    } else {

        echo "<script>alert('Invalid file format')</script>";

    }

}

?>

<div>

    

</div>

<div class="container-fluid pt-4 px-4 scroll" style="overflow: scroll;">

    <div style="padding: 2% 3%;" class=" bg-light rounded align-items-center justify-content-center mx-0">

        <form method="post" enctype="multipart/form-data">

            <div class="mb-3">

                <label for="exampleInputEmail1" class="form-label">Choose the File</label>

                <input type="file" name="doc" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">

            </div>

            <button type="submit" name="samudra" class="btn btn-primary">Submit</button>

        </form>

    </div>

    <div style="padding: 2% 3%;" class=" bg-light rounded align-items-center justify-content-center mx-0">

        <form method="post" action="bmcdata.php">

            <?php

            $query00 = " SELECT * from `samudra` where `status`=0";

            $res00 = mysqli_query($con, $query00);

            $row00 = mysqli_num_rows($res00);

            ?>

            <div style="display: flex;">

                <div class="mb-3" style="margin-right: 10%;">

                    <label for="exampleInputEmail1" class="form-label">Plant</label>

                    <select class="form-select" name="plant" required aria-label="Default select example">

                        <option selected></option>

                        <option value="1801">1801</option>

                        <option value="1802">1802</option>

                        <option value="1806">1806</option>

                        <option value="1807">1807</option>

                        <option value="1808">1808</option>

                        <option value="1809">1809</option>

                        <option value="1810">1810</option>

                        <option value="1811">1811</option>

                        <option value="1812">1812</option>

                        <option value="1851">1851</option>

                        <option value="1852">1852</option>

                    </select>

                </div>

                <div class="mb-3" style="margin-right: 10%;">

                    <label for="exampleInputEmail1" class="form-label">Date</label>

                    <input type="date" name="date" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">

                </div>

                <div class="mb-3">

                    <label for="exampleInputEmail1" class="form-label">Shift</label>

                    <select class="form-select" name="shift" required aria-label="Default select example">

                        <option selected></option>

                        <option value="Morning">Morning</option>

                        <option value="Evening">Evening</option>

                        <option value="Both">Both</option>

                    </select>

                </div>

            </div>

            <button type="submit" name="updatekg" class="btn btn-primary">Update <?php echo $row00 ?> rows values </button>

        </form>

    </div>

</div>


<?php

include("../footer.php");

?>

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  ...