<?php
//封装数据库
#$local--服务器名称
#$user--账号
#$pass--密码
#$db--数据库名称
function lin($local,$user,$db,$pass='root',$charset='utf8'){
$link=mysql_connect($local,$user,$pass);
mysql_select_db($db,$link);
mysql_query('set names '.$charset);
return $link;
}
//添加
#$table--表名
#data--数据
#$field--查询的位置
#$keys--装载数据(数组)的键名
#$vals--装载数据的(数组)数值
function insert($table,$data=array()){
$keys='';
$vals='';
foreach($data as $key => $val){//循环打印出需要的键名和数值
//得到的键值赋给变量,并且拼接一个英文逗号
$keys.="`$key`".',';
$vals.="'$val'".',';
}
//截取最后一个多出来的逗号
$keys=substr($keys,0,-1);
$vals=substr($vals,0,-1);
//查询数据的命令
$sql="insert into `$table`($keys)values($vals)";
mysql_query($sql);
$row=mysql_affected_rows();
return $row;//返回值
}
//单条数据查询
#$table--表名
#$where--条件
#$field--查询的位置
function single($table,$where,$field='*'){
$sql="select $field from `$table` where $where";
$res=mysql_query($sql);
$arr=mysql_fetch_assoc($res);
return $arr;
}
//全部数据查询
#$table--表名
#$field--查询的位置
function all($table,$field='*'){
$sql="select $field from `$table`";
$res=mysql_query($sql);
$list=array();
while($arr=mysql_fetch_assoc($res) ){
$list[]=$arr;
}
return $list;
}
//查询多条数据
#$table--表名
#$where--条件
#$offset--偏移量
#$fixed--分页显示的数量
#order--排序
#field--在哪里查询
function select($table,$where,$field='*'){
$sql="select $field from `$table` where $where ";
$res=mysql_query($sql);
$list=array();
while($arr=mysql_fetch_assoc($res)){
$list[]=$arr;
}
return $list;
}
//删除数据
#$table--表名
#$where--条件
function del($table,$where){
$sql="delete from `$table` where $where";
mysql_query($sql);
$row=mysql_affected_rows();
return $row;
}
//修改数据
#$table--表名
#$num--数据名称=数值
#data--数据
function modify($table,$where,$data=array()){
$field='';
foreach($data as $key => $val){
$field.="`$key`='$val',";
}
$field=substr($field,0,-1);
$sql="update `$table` set $field where $where";
mysql_query($sql);
$row=mysql_affected_rows();
return $row;
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
PHP实现Ajax方式和后台通过Json交互,认证码方式登录
共38个文件
php:14个
html:11个
jpg:10个
需积分: 10 18 下载量 123 浏览量
2017-06-27
17:15:32
上传
评论 1
收藏 83KB RAR 举报
温馨提示
实现了通过Ajax使用Json和后台交互的方式,MVC架构,并使用了认证码的技术
资源推荐
资源详情
资源评论
收起资源包目录
phpimagemvc.rar (38个子文件)
001phpimagemvc
index.php 604B
model
modify.php 514B
del-user.php 467B
index.php 145B
loginaction.php 2KB
destroy.php 186B
phpimage.php 1KB
login.php 151B
zck.php 760B
increase.php 867B
frameset.php 144B
inquire.php 964B
function.php 2KB
view
css
index.css 1KB
modify.html 2KB
images
dl_img.jpg 2KB
left_bg.jpg 342B
dl_bg.jpg 7KB
menu_bg_a.jpg 15KB
head_bg.jpg 430B
img.jpg 10KB
yzm.jpg 2KB
bg.jpg 5KB
menu_bg_b.jpg 12KB
bottom_bg.jpg 341B
increase.html 2KB
zck.html 1KB
login_old.html 3KB
hy.html 760B
login.html 3KB
index.html 978B
js
jquery-3.2.1.min.js 85KB
frameset.html 581B
left.html 1KB
inquire.html 3KB
login - 副本.html 3KB
dawn.sql 11KB
controller
democontroller.php 613B
共 38 条
- 1
资源评论
city789
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功