Filter tanggal eror

<!-------------TANGGAL------------>
                            <div class="row">
                                <div class="col">
                                    <form method="POST" class="form-inline">
                                        <input type="date" name="tgl_mulai" class="form-control">
                                        <input type="date" name="tgl_selesai" class="form-control ml-3">
                                        <button type="submit" name="filter_tanggal" class="btn btn-info btn-sm ml-3"> Cari </button>
                                    </form>
                            </div>
                        </div>
                                </div>
                                </div>
                                <div class="table-responsive  mt-1">
                                    <table class="table select-table">
                                        <thead>
                                        <div class="container">
                                </br>
                                            <tr>
                                                <th>#</th>
                                                <th style="text-align: center;">Username</th>
                                                <th style="text-align: center;">Tanggal</th>
                                                <th style="text-align: center;">Uraian Tugas</th>
                                                <th style="text-align: center;">Waktu</th>
                                                <th style="text-align: center;">Jumlah Kegiatan</th>
                                                <th style="text-align: center;">Waktu Efektivitas</th>
                                                <th style="text-align: center;">Total</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php

                                            if(isset($_POST['filter_tanggal'])){
                                                $mulai = $_POST['tgl_mulai'];
                                                $selesai = $_POST['tgl_selesai'];
                                                $result = mysqli_query($con,"SELECT * FROM tb_paru ORDER BY nama_depan AND tanggal BETWEEN '$mulai' AND DATE_ADD($selesai,INTERVAL 1 DAY");
                                            }

                                            $con=mysqli_connect("localhost","root","","db_hospital");
                                            if (mysqli_connect_errno())
                                            {
                                                echo "Failed to connect to MySQL: " . mysqli_connect_error();
                                            }
                                            $myUser = $access['username'];
                                            $result = mysqli_query($con,"SELECT * FROM tb_paru ORDER BY tanggal,nama_depan");

Hasil

image.png

avatar novaje
@novaje

28 Kontribusi 3 Poin

Diperbarui 2 tahun yang lalu

Tanggapan

Biasakan menjelaskan, bukan cuma copy paste kode

ok iyaaa bg

iyaa maaf bg

1 Jawaban:

<div>Coba pindahkan baris skrip koneksinya yang ini</div><pre>$con=mysqli_connect("localhost","root","","db_hospital");</pre><div><br>Ke atas bagian sebelum if isset POST</div>

avatar ahanafi
@ahanafi

815 Kontribusi 554 Poin

Dipost 2 tahun yang lalu

Tanggapan

udah ga eror bg, tp gbsa di filter tanggal nya bg

Login untuk ikut Jawaban