This time we will discuss about input data in database with form. Before that we have to know what database, Database is a place to store the data entered. In here we will use MySQL as Database management system (DBMS). Usually MySQL is included in the package xampp. To run MySQL in xampp we just need to click the start button on the control panel mysql, until the status is running, Let's see picture below.
After it we open CMD (Command prompt) at windows. And then we go in the directory that was installed xampp. In my computer xampp directory on drive D: ,so we must type in cmd D: and then open the folder that contains mysql.exe in the directory, type the text below in the CMD
D:\xampp\mysql\bin\mysql.exe -u root -p
If there is password to login MySQL Database fill with password which is you created, if no password just press enter. If in cmd there is text mysql > , database is ready for use.
Let's see picture below.
Because the data requires a database as data storage, we must make database and table in MySQL, Let's see steps below.
1. Create database in use cmd in MySQL below is the script.
CREATE DATABASE db_exercise;
If success, output as text below.
Query OK, 1 row affected (0.04 sec)
2. Select the database you want to use with the script below.
USE db_exercise;
If success, output as text below.
Database changed
3.Make table in database db_exercise, use script below to make table biodata.
CREATE TABLE biodata (
nim INT(5) NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(25) NOT NULL,
majors VARCHAR(25) NOT NULL,
address TEXT NULL
);
If success, output as text below.
Query OK, 0 rows affected (0.14 sec)
4. We have a database db_exercise and table bioodata. Now we will input data via CMD use script query(database script). Let's see below.
INSERT INTO biodata (name,address) VALUES('Riyan','Yogyakarta');
If success, output as text below.
Query OK, 1 row affected (0.07 sec)
To show data in table biodata we can use query script below.
SELECT id,name,address FROM biodata;
or
SELECT * FROM biodata;
Symbol * in the script above meaning is all of field in table biodata. We can reduce the search with writing only one field or more.
Below is output if script SELECT id,name,address FROM biodata; is running.
Input Data to Database with Form
..........
..........
Next steps create a form to input data into the database in Input Data in Database with Form Part 2 click here.
No comments:
Post a Comment