My College Fund

PHP & MySQL day 2: buat database

$host = "localhost";
$username = "root";
$password = "";
$dbase = "testdbase";

//membuat connection ke mysql
$connect = mysql_connect($host,$username,$password);
if(!$connect) {
echo "connection gagal: ".mysql_error();
}

//select database
mysql_select_db($dbase);

//buat query - sql statement
$qstaf = mysql_query("SELECT * FROM staf");
?>


//mendapatkan data dalam table
while($row = mysql_fetch_array($qstaf))
{
echo "";
echo "
";
}
echo "
NamaNo StafNoKPAlamat
$row[nama] $row[nostaf] $row[nokp] $row[alamat]
";
//tutup connection
mysql_close($connect);
?>

Tiada ulasan:

Catat Ulasan

Related Posts Plugin for WordPress, Blogger...