Praktek CRUD1 - Hallo sahabat Dev-Create, Pada Artikel yang anda baca kali ini dengan judul Praktek CRUD1, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan
Artikel Materi CRUD, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : Praktek CRUD1
link : Praktek CRUD1
<?php
$host = 'localhost';
$name = 'dbikaba';
$username = 'root';
$password = '';
$mysqli = mysqli_connect($host, $username, $password, $name);
if (mysqli_connect_errno()) {
echo "Koneksi gagal : ".mysqli_connect_error();
}
?>
ATAU :
=========================================================
<?php
$mysqli = mysqli_connect('localhost', 'root', '', 'crud_db');
if (mysqli_connect_errno()) {
echo "Koneksi gagal : ".mysqli_connect_error();
}
?>
<?php
// Create database connection using config file
include_once("koneksi2.php");
// Fetch all users data from database
$result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC");
?>
<html>
<head>
<title>Homepage</title>
</head>
<body>
<a href="add.php">Add New User</a><br/><br/>
<table width='80%' border=1>
<tr>
<th>Nomor</th> <th>Name</th> <th>Mobile</th> <th>Email</th> <th>Update</th>
</tr>
<?php
$nomor =1;
while($user_data = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$nomor ++."</td>";
echo "<td>".$user_data['name']."</td>";
echo "<td>".$user_data['mobile']."</td>";
echo "<td>".$user_data['email']."</td>";
echo "<td><a href='edit.php?id=$user_data[id]'>Edit</a> | <a href='delete.php?id=$user_data[id]'>Delete</a></td></tr>";
}
?>
</table>
</body>
</html>
Anda sekarang membaca artikel Praktek CRUD1 dengan alamat link https://dev-create.blogspot.com/2020/02/praktek-crud1.html
Judul : Praktek CRUD1
link : Praktek CRUD1
Praktek CRUD1
1. Membuat koneksi :
file : koneksi.php<?php
$host = 'localhost';
$name = 'dbikaba';
$username = 'root';
$password = '';
$mysqli = mysqli_connect($host, $username, $password, $name);
if (mysqli_connect_errno()) {
echo "Koneksi gagal : ".mysqli_connect_error();
}
?>
ATAU :
=========================================================
<?php
$mysqli = mysqli_connect('localhost', 'root', '', 'crud_db');
if (mysqli_connect_errno()) {
echo "Koneksi gagal : ".mysqli_connect_error();
}
?>
2. Halaman Index
file : index.php<?php
// Create database connection using config file
include_once("koneksi2.php");
// Fetch all users data from database
$result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC");
?>
<html>
<head>
<title>Homepage</title>
</head>
<body>
<a href="add.php">Add New User</a><br/><br/>
<table width='80%' border=1>
<tr>
<th>Nomor</th> <th>Name</th> <th>Mobile</th> <th>Email</th> <th>Update</th>
</tr>
<?php
$nomor =1;
while($user_data = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$nomor ++."</td>";
echo "<td>".$user_data['name']."</td>";
echo "<td>".$user_data['mobile']."</td>";
echo "<td>".$user_data['email']."</td>";
echo "<td><a href='edit.php?id=$user_data[id]'>Edit</a> | <a href='delete.php?id=$user_data[id]'>Delete</a></td></tr>";
}
?>
</table>
</body>
</html>
Demikianlah Artikel Praktek CRUD1
Sekianlah artikel Praktek CRUD1 kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel Praktek CRUD1 dengan alamat link https://dev-create.blogspot.com/2020/02/praktek-crud1.html