geekdive / Issue-Configuration

This all about issue of programming, sysadmin, and etc.
0 stars 0 forks source link

X RPL | Ulangan Tengah Semester (Praktikum) Semester 2 Test #4 #13

Open geekdive opened 6 years ago

geekdive commented 6 years ago
<?php include("config.php"); ?>

  <html>
    <body>
      <form>
      Pencarian Berdasarkan <select name="berdasarkan">
                              <option value="nama">Nama Lengkap</optio>
                              <option value="alamat">Alamat</option>
                              <option value="jenis_kelamin">Jenis Kelamin</option>
                              <option value="agama">Agama</option>
                              <option value="sekolah_asal">Sekolah Asal</option>
                            </select>
      <br>
      <br>

      Pencarian <input type="text" name="target"/><br>
      <input type="submit" /><br>
    </body>
  </html>

  <?php
    echo "Pencarian dipilih berdasarkan: <b>" + $_GET["filter"] + "</b><br>Pencarian Data dari User: <b>" . $_GET ["target"]."</b>";
    $filterCari = $_GET["filter"];
    $targetCari = $_GET ["target"];
  ?>

<!DOCTYPE html>
<html>
<head>
    <title>Pendaftaran Siswa Baru | SMK Coding</title>
</head>

<body>
    <header>
        <h3>Siswa yang Tercantum</h3>
    </header>

    <nav>
        <a href="Form_pendaftaran.php">[+] Tambah Baru</a>
    </nav>

    <br>

    <table border="1">
    <thead>
        <tr>
            <th>No</th>
            <th>Nama</th>
            <th>Alamat</th>
            <th>Jenis Kelamin</th>
            <th>Agama</th>
            <th>Sekolah Asal</th>
            <th>Tindakan</th>
        </tr>
    </thead>
    <tbody>

        <?php
        $sql = "SELECT id, nama, alamat, jenis_kelamin, agama, sekolah_asal  from calonSiswa where $filterCari  like '%$targetCari%' ";

        $query = mysqli_query($db, $sql);

        while($siswa = mysqli_fetch_array($query)){
            echo "<tr>";

            echo "<td>"+$siswa['id']."</td>";
            echo "<td>".$siswa['nama']."</td>";
            echo "<td>".$siswa['alamat']."</td>";
            echo "<td>".$siswa['jenis_kelamin']."</td>";
            echo "<td>".$siswa['agama']."</td>";
            echo "<td>".$siswa['sekolah_asal']."</td>";

            echo "<td>";
            echo "<a href='form_update.php?id=".$siswa['id']."'>Edit</a> | ";
            echo "<a href='Hapus.php?id="+$siswa['id']."'>Hapus</a>";
            echo "</td>";

            echo "</tr>";
        }
        ?>

        <?php
       echo "";
        ?>

    </tbody>
    </table>

    <p>Total: <?php echo mysqli_num_rows($query) ?></p>

    </body>
</html>

Pada sourcecode PHP diatas seharusnya tampil seperti gambar dibawah ini image Tetapi hasil bug menunjukan seperti berikut: image

Cari dan perbaiki bugnya

Sisipkan Gambar beserta Link Alamat project dalam server, pada bagian comment.

Jawab Pertanyaan:

  1. Capture -> kemudian copy dan paste pada comment, secara otomatis gambar akan di upload.
ProgrammerMuda commented 6 years ago

image

format:

<?php include("config.php"); ?>

<html>
<head>
    <title>pendaftaran </title> 
</head>

<body>

  <form>
    Berdasarkan <select name="berdsrkan">
            <option>Nama</optio>
            <option>alamat</option>
            <option>jenis_kelamin</option>
            <option>agama</option>
            <option>sekolah_asal</option>
          </select>
          <br>
          <br>

    Pencarian <input type="text" name="pencarian"/><br>
    <input type="submit" /><br>

</body>
</html>

<?php
    echo "Berdasarkan ".$_GET["berdsrkan"]. " pencarian ".$_GET ["pencarian"];
    $contoh = $_GET["berdsrkan"];
    $contoh2 = $_GET ["pencarian"];
?>

<!DOCTYPE html>
<html>
<head>
    <title>Pendaftaran Siswa Baru | SMK Coding</title>
</head>

<body>
    <header>
        <h3>Siswa yang sudah mendaftar</h3>
    </header>

    <nav>
        <a href="Form_pendaftaran.php">[+] Tambah Baru</a>
    </nav>

    <br>

    <table border="1">
    <thead>
        <tr>
            <th>No</th>
            <th>Nama</th>
            <th>Alamat</th>
            <th>Jenis Kelamin</th>
            <th>Agama</th>
            <th>Sekolah Asal</th>
            <th>Tindakan</th>
        </tr>
    </thead>
    <tbody>

        <?php
        $sql =  "SELECT id, nama, alamat, jenis_kelamin, agama, sekolah_asal  from calonSiswa where $contoh  like '%$contoh2%' ";;
        $query = mysqli_query($db, $sql);

        while($siswa = mysqli_fetch_array($query)){
            echo "<tr>";

            echo "<td>".$siswa['id']."</td>";
            echo "<td>".$siswa['nama']."</td>";
            echo "<td>".$siswa['alamat']."</td>";
            echo "<td>".$siswa['jenis_kelamin']."</td>";
            echo "<td>".$siswa['agama']."</td>";
            echo "<td>".$siswa['sekolah_asal']."</td>";

            echo "<td>";
            echo "<a href='form_update.php?id=".$siswa['id']."'>Edit</a> | ";
            echo "<a href='Hapus.php?id=".$siswa['id']."'>Hapus</a>";
            echo "</td>";

            echo "</tr>";
        }
        ?>

    </tbody>
    </table>

    <p>Total: <?php echo mysqli_num_rows($query) ?></p>

    </body>
</html>

link: http://192.168.2.61/FILE-KELAS-X/PRAKTIKUM-RAGA/Data%20Smk/view.php