Skip to main content

Membuat Combo berantai dalam satu database.

Simpan dalam dpl_data.php

<form method="POST" action="dkkn_tambah_simpan.php">

<tbody>
<tr> <input type="text" value="<?php echo $_GET['angkatan']; ?>" id="angkatan" name="angkatan" /></tr>

<tr><td>Nama DPL</td><td>:

<select name="nama" id="nama">
    <option value="">- Pilih Nama Dosen -</option>
   
    <!-- looping data nama -->
    <?php
    $sql_dosen="select * from tbdos";
    $q=$mysqli->query($sql_dosen);
    while($row_dosen=mysqli_fetch_array($q)){
   
    ?>
        <option value="<?php echo $row_dosen["nip"] ?>"><?php echo $row_dosen["nip"] ." - " . $row_dosen["nama"] ?></option>
   
    <?php
    }
    ?>
</select>

    &nbsp;&nbsp;&nbsp;<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
    <br>

<tr><td>NIK Dosen</td><td>: 
 <select name="kota" id="kota">
    <!-- hasil data dari cari_dosen.php akan ditampilkan disini ----------------------------------------------->
</select>


<tr><td>Type KKN</td><td>:
<select id="jenis" name ="jenis" />
<option value="Reguler 1" placeholder="Reguler I">Reguler 1
<option value="Reguler 2" placeholder="Reguler I">Reguler 2
<option value="Tematik" placeholder="Reguler I">Tematik
&nbsp;&nbsp;&nbsp;<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
</select>
</td></tr>

<tr><td>Tahun Akademik</td><td>:
<select id="tahun_akademik" name ="tahun_akademik" />
<?php include ("menu/listtakalender.php"); ?>
</select>
</td></tr>

<tr><td>Semester</td><td>:
<select  id="semester" name ="semester" />
<option placeholder="Pilih Semester">- Pilih Semester Ganjil/Genap
<option value="1" placeholder="">Ganjil
<option value="2" placeholder="">Genap
<option value="2" placeholder="">Antar Waktu
</select>
</td></tr>
</tbody>
</table>
<button type="submit" id="submit" class="btn btn-small btn-warning" ><a href="javascript:void(0)"></a><i class="icon-upload"></i> Simpan</button>

</form>



=============


Paling bawah ditambah script:
<script>
 
    $("#nama").change(function(){
 
        // variabel dari nilai combo box nama
        var nik = $("#nama").val();
     
        // tampilkan image load
        $("#imgLoad").show("");
     
        // mengirim dan mengambil data
        $.ajax({
            type: "POST",
            dataType: "html",
            url: "menu/cari_dosen.php",
            data: "prov="+nik,
            success: function(msg){
             
                // jika tidak ada data
                if(msg == ''){
                    alert('Tidak ada data Dose ');
                }
             
                // jika dapat mengambil data,, tampilkan di combo box kota
                else{
                    $("#kota").html(msg);                                                    
                }
             
                // hilangkan image load
                $("#imgLoad").hide();
            }
        });  
    });
</script>

Simpan dalam menu/cari_dosen.php
<?php
// server info
$server = 'localhost';
$user = 'root';
$pass = '';
$db = 'simpeg';

// connect to the database
$mysqli = new mysqli($server, $user, $pass, $db);

// show errors (remove this line if on a live site)
mysqli_report(MYSQLI_REPORT_ERROR);

?>  
<?php

 
    $sql_dosen1="select * from tbdos where nip='".$_POST["prov"]."'";
    $q=$mysqli->query($sql_dosen1);
    while($row_dosen1=mysqli_fetch_array($q)){
 
    ?>
        <option value="<?php echo $row_dosen1["nip"] ?>"><?php echo $row_dosen1["nip"] ?></option><br>
 
    <?php
    }
    ?>

Comments

Popular posts from this blog

Menggenerate nomor id

<?php //config $database = "dopo"; $tabel = "po"; $kolom_generate ="id"; $kolom_referensi = "id"; /* Database connection start */ $servername = "localhost"; $username = "root"; $password = ""; $dbname = $database; $mysqli = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); $q1 = "select * from $tabel order by $kolom_referensi DESC"; /* Database connection end */ echo '<table>'; // connect to the database // number of results to show per page $per_page = 10000; // figure out the total pages in the database if ($result = $mysqli->query($q1)) { if ($result->num_rows != 0) { $total_results = $result->num_rows; // ceil() returns the next highest integer value by rounding up value if necessary $total_pages = ceil($total_results / $per_page); // check if the 'page' variab...

Hack File .xlsb

For first you must create a backup copy of your Workbook!!! Then you have to rename the XLSB file with ZIP extension. Test.XLSB => Test.ZIP             Opening your ZIP file using a compression software (e.g. WinRar) I can see the content of the file, structured in folders Inside the folder xl you can find a binary file named vbaProject.bin. Extract it on your desktop and edit it using a text editor. In my case I used Notepad++. Using the Find function of your editor, you must search the text DPB And replace the DPB string with DPx Then save the vbaProject.bin and replace this file inside the .ZIP File, renaming then .ZIP file in XLSB. Reopening the XLSB file using Excel, you will get an error message: you have to answer Yes to this error message. Then  Save , Close and Reopen your XLSB file. Now, if you go to VBA Editor (ALT + F11), you ca...

Instal font baru di FPDF.

1. buka url www.fpdf.org/makefont 2. pilih ttf yang akan dimasukkan. sebaiknya pindahkan file ttf dari c:/windows/font ke folder lain. karena C: adalah windows. 3. Upload dan generate. 4. Donwload nama font.php dan font.z copykan ke folder fpdf/font. <?php require( 'fpdf.php' ); $pdf = new FPDF (); $pdf -> AddFont ( 'Calligrapher' , '' , 'calligra.php' ); $pdf -> AddPage (); $pdf -> SetFont ( 'Calligrapher' , '' , 35 ); $pdf -> Write ( 10 , 'Enjoy new fonts with FPDF!' ); $pdf -> Output (); ?>