This tutorial is all about Insert and Display Data in PHP & MYSQL Without Refreshening Page. In this tutorial you will learn Insert and Display Data in PHP & MYSQL Without Refreshening Page.
Good Day! Everyone! Today I’m going to teach you my inserting and displaying data in your database. Unlike with my previous tutorial which is about a very simple way in inserting and showing data in database. Here, you don’t need to refresh your page in order to display the inserted data and we add some styles now.
So before you go with this tutorial, for the beginners, I suggest to start with my previous tutorial regarding simple way of inserting and displaying data in PHP. >> click here << to go my previous article.
So now, we will going to start our tutorial.
Make sure you already have the following. You can download it below:
Now, if you are already done downloading all the files below. Just go now to your browser then go to PHPMYADMIN to create a database.
Create a database then name it as any name you desire. In my case, I use “itsourcecode” as the name of the database.
Then create a table. Put “mydata” as the table name then put the following attributes.
CREATE TABLE `mydata` (`id` int(11) NOT NULL, `name` text NOT NULL, `age` int(11) NOT NULL, `gender` text NOT NULL, `birthday` date NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Now for the connection to the database. Create a “connection.php” file then put the following codes.
<?php
date_default_timezone_set(‘Asia/Manila’);
$servername = ‘localhost’;
$username = ‘root’;
$password = ”;
$dbname = ‘itsourcecode’;
try {
$conn = new PDO(“mysql:host=$servername;dbname=$dbname”, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $ex) {
echo “Connection Failed: “. $ex->getMessage();
}
?>
As you can see, we now upgraded our coding structure in managing our database using PDO. This is now the updated version in MYSQL.
Now, create a “index.php” file then put the following codes.
<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<title>Inserting Data Without Refreshing the Page</title>
<link href=”assets/css/bootstrap.min.css” rel=”stylesheet” type=”text/css”/>
http://assets/js/jquery-3.2.1.min.js
http://assets/js/bootstrap.min.js
</head>
<body>
Inserting Data in PHP/MYSQL Without Refreshing the Page
</div>
Name | Age | Gender | Birthday |
---|
</div>
<!– Start Add Data Modal –>
Sir have you any complete project like this not winrar file complete project every thing clear like this coding