Now I will explain how to read data with PHP below is complete code: |
<?
// database connection
$conn= mysql_connect ("localhost","root","") or
die ("sorry wrong username or password");
$db = "dataku";
mysql_select_db($db, $conn);
// judul table
echo "<table border='1'>";
echo "<tr>";
echo "<td>nama</td><td>nim</td><td>jurusan</td>";
echo "</tr>";
// baca recordset
$sql="select nim,nama,jurusan from mahasiswa";
$rs = mysql_query($sql,$conn) or die ("Kesalahan pada pembacaan recordset");
for($i=0;$i<mysql_num_rows($rs);$i++){
$row_array=mysql_fetch_row($rs);
echo "<tr>";
echo "<td>".$row_array[0]."</td><td>".$row_array[1]."</td><td>".$row_array[2]."</td>";
echo "</tr>";
}
echo "</table>";
?>
|
If source code run well you may see like below: |
Showing posts with label how to read data with php script. Show all posts
Showing posts with label how to read data with php script. Show all posts
Monday, February 1, 2016
how to read data with php script
Subscribe to:
Posts (Atom)