AJAX stands for Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages.
AJAX is used to creating dynamic and fast website pages. AJAX is known as a technique through which you can create a kind of website.
You can display (fetch) data from the MYSQL table using PHP and AJAX. AJAX helps you to fetch data from the MySQL table without reloading (refreshing) the PHP page. You can search for data, filter by date and edit data on the same page without refreshing (reloading) page. AJAX technique is a fast technique for the process of the data between the PHP page and MYSQL database table.AJAX helps to update parts of a web page, without reloading the whole page. Display the data from the MySQL table and filter by the days and month etc without reloading the page. If you do not want to use AJAX then you have to reload all PHP pages after the update, edit, delete. Most of the popular websites are using AJAX bellow -
Google(Gmail, map ), Youtube, and Facebook tabs.
To display or fetch data from the MYSQL database table then you have to create a database and a table. Insert some data into the table.
Create MYSQL database table
Database name "technosmarter"
table name "persons "
CREATE TABLE `persons` (
`id` int(50) NOT NULL,
`fname` varchar(40) NOT NULL,
`lname` varchar(30) NOT NULL,
`email` varchar(50) NOT NULL,
`address` varchar(50) NOT NULL,
`mobile` varchar(50) NOT NULL,
`password` varchar(40) NOT NULL,
`acno` varchar(40) NOT NULL,
`bank_name` varchar(30) NOT NULL,
`owner_name` varchar(30) NOT NULL,
`ac_type` varchar(30) NOT NULL,
`ifsc` varchar(50) NOT NULL,
`name` blob NOT NULL,
`date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
We created a table for fetch data via PHP and Ajax.
We have taken some table fields
-
id` int(50) NOT NULL,
`fname` varchar(40) NOT NULL, = First Name (fetch by Ajax column 2)(Display)
`lname` varchar(30) NOT NULL, = Last Name (fetch by Ajax column 2)(Display)
`email` varchar(50) NOT NULL, = Email (fetch by Ajax column 3)(Display)
`address` varchar(50) NOT NULL, = Address (fetch by Ajax column 4)(Display)
`mobile` varchar(50) NOT NULL,= Mobile (fetch by Ajax column 5)(Display)
`password` varchar(40) NOT NULL,= Password (Not fetch )(Not Display)
`acno` varchar(40) NOT NULL, = Account Number (fetch by Ajax column 6)(Display)
`bank_name` varchar(30) NOT NULL, = Bank Name (fetch by Ajax column 6)(Display)
`owner_name` varchar(30) NOT NULL,= Accont Holder Name (fetch by Ajax column 6)(Display)
`ac_type` varchar(30) NOT NULL, = Account Type (fetch by Ajax column 6)(Display)
`ifsc` varchar(50) NOT NULL, = IFSC Code (fetch by Ajax column 6)(Display)
`name` blob NOT NULL, = Image Name(fetch by Ajax column 1)(Display)
`date` date NOT NULL = Date( fetch data Filter by date ) (Display)
You want to display the data from the database then you need to insert some data in the table.
Insert some data in the table and fetch through PHP and Ajax.
INSERT INTO `persons` (`id`, `fname`, `lname`, `email`, `address`, `mobile`,
`password`, `acno`, `bank_name`, `owner_name`, `ac_type`, `ifsc`,`date`) VALUES
(81, 'Mohan', 'Rana', '[email protected] ', 'Shamli', '7812828887', 'admin@123',
'739837927193', 'SBI', 'Mohan Rana', 'Saving ', 'SBI00875464',
'2019-09-18');
In the above insertion, you can insert all data and fetch via ajax and display it on the webpage.
Make a connection file
When we work on MYSQL database ,we need a connection between MYSQL database and PHP script.
The data is displayed through the PHP and AJAX on the page after database connectivity.
Let's create a config file.
Create a table for display data by Ajax techniques
Now we will fetch data and display it in the table using Ajax. Create a simple table and columns name.
Select Days
In 180 Days
In 90 Days
In 60 Days
In 30 Days
User Image
Full Name
Email
Mobile
Address
Payment Details