Php-Mysql: Week 5 Dynamic Web Programming
Php-Mysql: Week 5 Dynamic Web Programming
Week 5
Databases
Databases
Login form
Retrieval of user login data in the database and match it with input data from the user
List table
Display data in a table (ex: student list table)
Details
Displays detailed data from a table (eg details of student biodata based on a
certain NIM)
Data Definition Language (DDL)
Example:
create student table
(
NIM char(10) primary key,
name char(30) not null,
class char(30) not null,
address char(40) not null,
);
Query
Extensions:
MySQL
MySQLi
Connection files
DB server settings: Server, Username, Password
<?php
$connect= mysqli_connect('localhost','root','pass'); if($connect){
<?php
$select_db= mysql_select_db('project'); if($select_db){
$host = 'localhost';
$user = 'root';
$db = 'informatics';
<?php
$sql = "insert into student(nim,name) values('123','Budi')"; $query =mysqli_query($sql);
if($query){
<?php
$sql = “update student set name='Budi' where nim='123'”; $query =mysqli_query
($sql); if($query){
<?php
$sql = “delete from student where nim='123'”; $query =
mysqli_query($sql); if($query){
while(mysqli_fetch_array(mysqli_query(“Your_Query”))){
//Your_Action
<?php
$sql = “select * from student where nim='123'”; $query =
mysqli_query($sql); While($row=mysqli_fetch_array($query))
{ echo “$row['nim'] $row['name']”;
}
?>
practice
1. Create a database that has a table ''students'' with the attribute: id int auto
increment
nim char 10
name varchar 100
email varchar 100
varchar 100
varchar 100 . image
1. Follow the Steps from the given tutorial module 5 so that the data in the student table can be
displayed in the browser using a connection to the database.
2. Put the results of the exercise in 1 folder, send it to OL with the name: NIM_class_modul5.zip / .rar
3. Due date: next week
END