0% found this document useful (0 votes)
14 views3 pages

KONEKSI

The document connects to a database and displays student data from a table in the database in a datatable. It connects to the database, includes a connection file, selects and displays the student data from the table including number, ID, name, gender and phone number.

Uploaded by

Thuty Setiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

KONEKSI

The document connects to a database and displays student data from a table in the database in a datatable. It connects to the database, includes a connection file, selects and displays the student data from the table including number, ID, name, gender and phone number.

Uploaded by

Thuty Setiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

KONEKSI

<?php

$dbuser ='root';

$dbpassword = '';

$dbname = 'kampus';

$con = mysqli_connect('localhost',$dbuser,$dbpassword,$dbname);

?>

TAMPIL

<html>

<head>

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>

<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>

<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>

<link href ="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css"rel


="stylesheet">

<link href ="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css"rel


="stylesheet">

<script>

$(document).ready(function() {

$('#example').DataTable();

});

</script>

</head>

<?php

include 'Koneksi.php';
?>

<h2> Data Mahasiswa </h2>

<br>

<table id="example" class="table table-striped table-bordered" style="width:100%">

<thead>

<tr>

<th>No.</th>

<th>NIM </th>

<th>Nama Lengkap </th>

<th>Jenis Kelamin </th>

<th>Nomor Telepon</th>

</tr>

</thead>

<tbody>

<?php

$no =1;

$data = mysqli_query($con,"Select * from mahasiswa");

while($d = mysqli_fetch_array($data)){

?>

<tr>

<td><?php echo $no++; ?></td>

<td><?php echo $d['nim']; ?></td>

<td><?php echo $d['namalengkap']; ?></td>

<td><?php

IF($d['jk']==0){

$jk = 'Wanita';
}else{

$jk = 'Pria';

echo $jk;

?></td>

<td><?php echo $d['hp']; ?></td>

</tr>

<?php

?>

</tbody>

</table>

</html>

You might also like