如何使用php mysql将属性从下拉列表保存到下几页

时间:2017-11-22 11:52:53

标签: php mysql dropdown

我从下拉页面获取此代码。(不是全部)

 <center><h4 class="page-header">PEPERIKSAAN : <?php

        $peperiksaan_nama=$_POST["peperiksaan_id"];
        echo $peperiksaan_nama ?> <br>
        MATAPELAJARAN : Matematik <br>
        KELAS : <?php 
        $kelas_nama=$_POST['kelas_id'];
        $darjah_nama=$_POST['darjah_id'];
            echo $darjah_nama; ?> <?php
            echo $kelas_nama; ?> <br> 
        TAHUN : <?php  $tahun_nama=$_POST['tahun_id']; echo $tahun_nama?>
    </h4></center> 

<center>    <form id="import" name="import" method="post" enctype="multipart/form-data">
    <input type="file" name="file" /><br />
    <input class="btn btn-primary" type="submit" name="submit" value="Import"/> <br><br>
</form>  </center>

<?php

if(isset($_POST["submit"]))
{
    $file = $_FILES['file']['tmp_name'];
    $handle = fopen($file, "r");
    $c = 0;
    while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
    {

        $murid_ic = $filesop[0];
        $murid_nama = $filesop[1];
        $murid_markah = $filesop[2];
        $murid_gred = $filesop[3];
        $tahun_id = $filesop[4];
        $peperiksaan_id = $filesop[5];
        $kelas_id = $filesop[6];
        $darjah_id = $filesop[7];    


        $query = query("INSERT INTO murid (murid_ic,murid_nama, murid_markah, murid_gred, tahun_id, peperiksaan_id, kelas_id, darjah_id) 

        VALUES ('$murid_ic','$murid_nama','$murid_markah','$murid_gred','$tahun_id','$peperiksaan_id','$kelas_id','$darjah_id')");

        $c = $c + 1;
    }

        if($query){

            redirect("index.php?pages=peperiksaan2&tahun_id=$tahun_id&peperiksaan_id=$peperiksaan_id&darjah_id=$darjah_id&kelas_id=$kelas_id");
                echo "You database has imported successfully. You have inserted ". $c ." recoreds";
        }else{
            echo "Sorry! There is some problem.";
        }

}
?>


    <table width="100%" class="table table-striped table-bordered table-hover">
        <thead>
                <tr>
                    <th>BIL</th>
                    <th>NAMA</th>
                    <th>NO IC</th>
                    <th><center>MARKAH</center></th>
                    <th><center>GRED</center></th>
                </tr>   
              </thead>

        <?php            

            $bil = 0;

            $SQLSELECT = "SELECT murid.*, peperiksaan.*, tahun.*, darjah.*, kelas.* FROM murid, peperiksaan, tahun, darjah, kelas WHERE murid.peperiksaan_id = peperiksaan.peperiksaan_id AND murid.tahun_id = tahun.tahun_id AND murid.darjah_id = darjah.darjah_id AND murid.kelas_id = kelas.kelas_id" ;

            $result_set =  mysqli_query($con, $SQLSELECT);

            while($row = mysqli_fetch_array($result_set))
            {
                $bil++;
            ?>

                <tr>
                    <td><?php echo $bil; ?></td>
                    <td><?php echo $row['murid_nama']; ?></td>
                    <td><?php echo $row['murid_ic']; ?></td>
                    <td><center><?php echo $row['murid_markah']; ?></center></td>
                    <td><center><?php echo $row['murid_gred']; ?></center></td>     

                </tr>


            <?php
            }
        ?>              

这是从下拉列表中选择选项后的页面,用户需要根据所选的选项导入文件..(下面几个代码)

transportСompanyId



碰巧很好..但是在导入文件之后......属性不再读取选项中的值。为什么会这样?无论如何,导入按钮会指向同一页面。

1 个答案:

答案 0 :(得分:0)

将您的值存储在Cookie中并在需要时使用