Home » , » Tutorial Menampilkan Database MySql dengan PHP

Tutorial Menampilkan Database MySql dengan PHP

Written By Unknown on Thursday, 9 August 2012 | 02:42


Tutorial ini saya buat karena saya ingat pas perta makali saya belajar untuk menampilkan data mysql dengan php
seperti ini koding sob:


<?php //setting koneksi anda
$server = "localhost";
$username = "root";
$password = ".....";//isikan passs nya
$db = ".....";//isikan nama databasenya
$tbl = ".....";//isikan nama tablenya

$koneksi = mysql_connect($server,$username,$password);
mysql_select_db($db, $koneksi) or die("Cannot connect to database..");
?>
<table width="97%" border="1" cellspacing="1" cellpadding="1">
  <tr bgcolor="#BBBBBB" align="center">
    <td>NO</td>
    <td>Contoh 1</td>
    <td>Contoh2</td>
    <td>Contoh3</td>
    <td>Contoh4</td>
 
  </tr>
  <?php
  $no = 1;
  $cari   = " SELECT * FROM ".$db.".".$tbl.
  " order by ID desc ";
while ($hasil = mysql_fetch_array ($cari))
?>
  <tr>
    <td>&nbsp;<?=$no;?></td>
    <td>&nbsp;<?=$hasil['isidalam table'];?></td>
    <td>&nbsp;<?=$hasil['isidalam table'];?></td>
    <td>&nbsp;<?=$hasil['isidalam table'];?></td>
    <td>&nbsp;<?=$hasil['isidalam table'];?></td>
   
 
  </tr><? $no++; }?>
</table>

Kurang dan  lebihnya mohon ma'af
kalau ada yang salah jangan sungkan sob untuk komen nya.

Share this article :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Turorial Grapich Design and Blog Design - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger