Creating Custom Admin Pages and Display Data from Database | WordPress
Creating Custom Admin Pages and Display Data from Database in WordPress. I’ve shown you Customs form that store input in the database whic...
https://bethedev.blogspot.com/2016/12/creating-custom-admin-pages-and-display.html
Creating Custom Admin Pages and Display Data from Database in WordPress. I’ve shown you Customs form that store input in the database which is my previous tutorial. Now what if you already have a set of data in Database, but you want to display data ( gridview ) database in Wordpress admin page.
Creating a Top-Level Admin Page
The first step is to create a menu entry with the add_menu_page() function. Here’s a full example. Explanation
Now you can view data through WordPress admin dashboard!
If you have any questions please post your comments below.
Requirements
- Your own self-hosted WordPress site, obviously.
- Basic PHP and MySQL skills
- An existing dataset in MySQL.
What Are We Going to Do Before Coding?
Create a relevant table on Database, I have created Table like below (MySQL Code).
Insert some dummy data into Table.
CREATE TABLE `request` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, `Email` varchar(255) DEFAULT NULL, `Service` varchar(25) DEFAULT NULL, `Date` date DEFAULT NULL, `Address` varchar(255) DEFAULT NULL, `Phone` int(11) DEFAULT NULL, `Message` varchar(100) DEFAULT NULL, `status` varchar(10) NOT NULL DEFAULT 'start', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
Making a Custom Admin Page
There are two or three components to an admin page, depending on the functionality you are building;
1, A menu entry – top-level or sub-level
1, A menu entry – top-level or sub-level
2, The page content
3, Processing logic for forms – if needed.
Creating a Top-Level Admin Page
Project Example.
According to my project below the example file for function.php. Add following php code into function.php file. You can find function.php file in wp-content\themes\<<Your Theme Name>> then you add code into top of your function.php.
According to my project below the example file for function.php. Add following php code into function.php file. You can find function.php file in wp-content\themes\<<Your Theme Name>> then you add code into top of your function.php.
Now you can view data through WordPress admin dashboard!
If you have any questions please post your comments below.
Thank you!
Thanks Really For Your Support And Great Tutorial
ReplyDeleteTill Now Everything Running Well In The Tutorial I Have Just Small Question i Already Created Form In The Form I Have Little Problem How I Create Table Stored In The Database Like This Example + Table For Family Members And Some Details About them Like This Table
--------
after data stored in this table
--
CREATE TABLE `request` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(255) NOT NULL,
`Email` varchar(255) DEFAULT NULL,
`Service` varchar(25) DEFAULT NULL,
`Date` date DEFAULT NULL,
`Address` varchar(255) DEFAULT NULL,
`Phone` int(11) DEFAULT NULL,
`Message` varchar(100) DEFAULT NULL,
`status` varchar(10) NOT NULL DEFAULT 'start',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
===
i want the customer fill like this table in the form and stored in the database
+----------+---------+--------------+
| Number | Name | Phone Number |
+----------+---------+--------------+
| 1 | Ann | 1234568 |
| 2 | Mathew | 1234567 |
| 3 | | |
+----------+---------+--------------+
Please refer this http://www.bethedev.com/2016/12/insert-data-in-database-using-form-in.html
Delete