<html>
<head>
<title>MAKLUMATPELAJAR</title>
<style>
table {
border-collapse:collapse;
width:100%;
color: #000000;
font-family:monospace;
font-size:25px;
text-align:left;
}
th {
background-color:#660066;
color:white;
}
tr:nth-child(even){background-color:#f2f2f2}
</style>
</head>
<body>
<table>
<tr>
<th>ID PELAJAR</th>
<th>NAMA</th>
<th>NO TELEFON</th>
</tr>
<?php
$conn = mysqli_connect("localhost","root","","db_sambungan");
// Uji Sambungan
if ($conn->connect_error) {
die("Connectionfailed:". $conn->connect_error);
}
$sql = "SELECT id_pelajar,nama_pelajar,notel_pelajarFROMtb_pelajar";
$result= $conn->query($sql);
if ($result->num_rows>0) {
// Outputdata setiapbaris
while($row =$result->fetch_assoc()) {
echo"<tr><td>" . $row["id_pelajar"]."</td><td>". $row["nama_pelajar"] ."</td><td>"
. $row["notel_pelajar"]."</td></tr>";
}
echo"</table>";
} else { echo"0 results";}
$conn->close();
?>
</table>
</body>
</html>

TICT #13