Friday, November 1, 2019

Cari

Name File: cari.php
Ketik script di bawah ini:

<html>
<body>
<?php
//koneksi ke database mysql, silahkan di rubah dengan koneksi agan sendiri
$koneksi = mysqli_connect("localhost","root","","stmikj2");

//cek jika koneksi ke mysql gagal, maka akan tampil pesan berikut
if (mysqli_connect_errno()){
 echo "Gagal melakukan koneksi ke MySQL: " . mysqli_connect_error();
}
?>

<form action="" method="get">
 <label>Cari :</label>
 <input type="text" name="cari">
 <input type="submit" value="Cari">
</form>

<?php
if(isset($_GET['cari'])){
 $cari = $_GET['cari'];
 echo "<b>KDMK: ".$cari."</b>";
}
?>

<table border="1">
 <tr>
  <th>KDMK</th>
  <th>MK</th>
 </tr>

 <?php
 if(isset($_GET['cari'])){
  $cari = $_GET['cari'];
 
  $data = mysqli_query($koneksi,"select * from mk where kdmk like '%$cari'"); 
 }
 else{
  $data = mysqli_query($koneksi,'select * from mk');
 }
 //$no = 1;
 while($d = mysqli_fetch_array($data)){
 ?>
 <tr>
  <td><?php echo $d['kdmk'];?></td>
  <td><?php echo $d['mk'];?></td>
 </tr>
 <?php } ?>
</table>

</body>
</html>
Bitcoin Offers:
Free Bitcoin, Double Bitcoin, Bitcoin Investment, Bitcoin Trading



"Bitcoin and Forex are high risk business. We must join them smartly."

No comments:

Post a Comment