How To Create Students Database
How To Create Students Database
How To Create Students Database
Create a table
1. Add Name and Number of columns
2. Create entities/column names
3. Name the first column as ID
6. Birthday
• Null Index – set as primary key
7. Gender
4. Add First_Name (no spacing) 8. Enrolled_Date
5. Last_name (no spacing)
Add data to your Database MySQL
3 way to add data
2. Go to SQL tab
Click Insert
Then add values
3. Go to IMPORT tab
Then you can import here the database you have created from
other computer applications ex. Microsoft Excel (.csv)
Displaying Data and Creating connection
• In browser type
http://localhost/school_database
Add query
$row = $students->fetch_assoc();
VS code
(add echo if you want to display result)
do{
}while($row = $students->fetch_assoc());
?>
</body>
</html>
include_once("connections/connection.php");
$con = connection();
• Insert.php file
2. Run
3.
Creating User Accounts and Access
Add a log in page (ex. login.php)
1. Create a login.php file
2. Copy the codes from index.php
3. Delete $sql To check if the codes are working
4. Delete <body> content successfully try to write an echo.
5. Write $_SESSION
>if (isset($_POST['login'])){
6. Write isset
echo "Login";
}
if(!isset($_SESSION)){
session_start();
}
login.php <body>
Create another table in MySQL
1. Create a table name ex. (user_accounts)
2. Add entities/columns names
• ID
• username
• password
• access
3. Add data for Administrator and Users using INSERT TAB
• Username
• Password
• Access
// echo "Login";
$username = $_POST['username'];
$password = $_POST['password'];
}
login.php
Create logout.php file
index.php
Create
details.php file
*Run
*It will display view and if you log in as Administrator it will allow you to see the
details.
Using GET method add a parameter
<a href="delete.php">Delete</a>
<br/>
Creating edit features
*Run
*You don’t see any information because we need to pass the ID to
edit.php.
In edit.php
$id = $_GET['ID'];
$sql = "SELECT * FROM list_of_students WHERE ID ='$id'";
$students = $con->query($sql) or die ($con->error);
$row = $students->fetch_assoc();
In details.php
In edit.php
$id = $_GET['ID'];
$sql = "SELECT * FROM list_of_students WHERE ID ='$id'";
$students = $con->query($sql) or die ($con->error);
$row = $students->fetch_assoc();
In edit.php
In edit.php
In edit.php
• Add query
Change INSERT to UPDATE
*Run
*First name and last name are already updating
In edit.php
• Create options for gender
In details.php
• Then run
In edit.php
Change submit to update
In delete.php