Jquery php method to implement real-time data update: 1. Create a data table; 2. Connect to the database by creating the server file "demo.php" and perform related operations; 3. Create "fresh.html" to display the data Just the web page.
#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
How does jquery php implement real-time data update?
php jQuery ajax implemented real-time refresh display data function example
The details are as follows:
Create data table: demo
-- -- 表的结构 `demo` -- CREATE TABLE IF NOT EXISTS `demo` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=5 ; -- -- 转存表中的数据 `demo` -- INSERT INTO `demo` (`id`, `name`) VALUES (1, '雷军'), (2, '马化腾'), (3, '李彦宏'), (4, '马云');
Server file: demo.php
set_charset('utf8'); $query = 'SELECT * FROM demo'; $result = $mysqli->query($query); $arr = $result->fetch_all(MYSQLI_ASSOC); $info = json_encode($arr); echo $json = '{"success":true,"info":'.$info.'}';
Display data web page: fresh.html
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of How to implement real-time data update in jquery php. For more information, please follow other related articles on the PHP Chinese website!