Catatan Seorang Prajurit Kecil

Ikon

biarlah semua itu berjalan sesuai "skenario" NYA – jika kau telusuri, semua logika itu akan kau temukan

Meampilkan Struktur Database Menggunakan PHP


Friendz,,,, kali ini q coba bikin script sederhana untuk menampilkan struktur database menggunakan bahasa php, sorry kalo udah basi, kali aja ada yang baru mau belajar php😉

<?php

$con = mysql_connect(“localhost”,”root”,””);

$sql = “SHOW DATABASES”;

$result = mysql_query($sql);

echo “<form action=’index.php’ method=’POST’>”;

echo “Database : <select name=’cmb_db’>”;

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

echo “<option value=’$data[0]’>$data[0]</option>”;

}

echo “</select> <input type=’submit’ name=’sbm_db’ value=’ Show Tables ‘>”;

echo “</form>”;

if((isset($_POST[“sbm_db”])) || (isset($_POST[“sbm_tb”]))){

echo “<form action=’index.php’ method=’POST’>”;

mysql_select_db($_POST[“cmb_db”]);

$sql_tb = “SHOW TABLES”;

$result_tb = mysql_query($sql_tb);

echo “<br>Tabel : <select name=’cmb_tb’>”;

while($data_tb = mysql_fetch_array($result_tb)){

echo “<option value=’$data_tb[0]’>$data_tb[0]</option>”;

}

echo “</select> <input type=’submit’ value=’ Show Fields ‘ value=’sbm_tb’>”;

echo “</form>”;

}

if(isset($_POST[“sbm_tb”])){

$sql_fl = “SHOW FIELDS FROM $_POST[cmb_tb]”;

echo $sql_fl;die;

$result_fl = mysql_query($sql_fl);

while($data_fl = mysql_fetch_array($result_fl)){

echo $data_fl[0].” – “.$data_fl[1].”<br>”;

}

}

?>

Filed under: Programing, Pure PHP

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: