02 Februari 2011

Membuat Tampilan database dengan PHP/HTML

Berikut adalah code untuk menampilkan database kedalam bentuk halaman web dengan menggunakan script PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Data Mahasiswa</title>

<style type="text/css">

<!--

.style2 {font-size: 16pt}

-->

</style>

</head>

<body>


<table width="668" border="1" align="center">

<tr>

<th colspan="5" align="center" valign="bottom" nowrap="nowrap" bgcolor="#00FF99">

<div align="center">

<h1 class="style2">Data Mahasiswa Jurusan Fisika Prodi Kependidikan</h1>

<p class="style2"><img src="Images/logo.jpg" width="134" height="90" /></p>

<h1>Universitas Negeri Medan</h1>

</div></th>

</tr>

<tr>

<td bgcolor="#00FFFF"><div align="center"><b>NIM</b></div></td>

<td bgcolor="#00FFFF"><div align="center"><b>Nama Lengkap</b></div></td>

<td bgcolor="#00FFFF"><div align="center"><b>J.Kelamin</b></div></td>

<td bgcolor="#00FFFF"><div align="center"><b>Asal SMA</b></div></td>

<td bgcolor="#00FFFF"><div align="center"><b>Jurusan</b></div></td>

</tr>


<?php

include "mssql-ok.php";

$sql_mhs = "SELECT * FROM mhs ORDER BY nim ASC";

$qry_mhs = mysql_query($sql_mhs);

while ($data = mysql_fetch_array($qry_mhs)) {

?>


<tr>

<td width="102"><?php echo $data['nim']; ?></td>

<td width="199"><?php echo $data['nama']; ?></td>

<td width="76"><div align="center"><?php echo $data['kelamin']; ?> </td>

<td width="185"><?php echo $data['asal_sma']; ?></td>

<td width="72"><?php echo $data['jurusan']; ?></td>

</tr>

<?php

}

mysql_free_result($qry_mhs);

mysql_close($conn);

?>

</table>


</body>

</html>



Simpan file dengan nama "MhsTampil.php"......


Next >>



0 komentar: