Home>Article>Web Front-end> ajax combined with mysql database to achieve partial data refresh

ajax combined with mysql database to achieve partial data refresh

php中世界最好的语言
php中世界最好的语言 Original
2018-03-30 15:41:24 2305browse

This time I will bring you ajax combinationmysql databaseTo achieve partial data refresh, ajax combined with mysql database to achieve partial data refreshWhat are the precautions, the following is a practical case, one Get up and take a look.

Effect status: switch between status lock and non-lock by clicking on the lock status

1. Main program: 01.php imports smarty and mysql classes, and obtains the data import list template

getALL('users'); $smarty->assign('lists',$lists); $smarty->display('list.html'); ?>

2. The list template uses smarty Traverse the template data and display it, in which ajax is called to change the lock status

    用户权限展示表 

用户权限表

{foreach $lists as $list} {if $list.is_lock==1} {else} {/if} {if $list.role==1} {else} {/if} {/foreach}
uid用户名密码锁定状态角色
{$list.uid} {$list.username} {$list.password}锁定取消锁定管理员编辑者

3.ajax response script, receives the data passed by ajax through the get method, changes the database content and The response text is sent back to the js script

update('users',"is_lock=$lock","uid=$uid"); if($result){ echo true; }else{ echo false; } ?>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Detailed graphic explanation of ajax implementation of dynamic pie charts and column charts

Determine whether it is an integer , what are the ways to write regular numbers for decimals or real numbers

The above is the detailed content of ajax combined with mysql database to achieve partial data refresh. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn