返回mysqli学......登陆

mysqli学习小总结

cherry2019-03-02 18:55:00230
//查出数据库中按年龄的倒叙排列的最后两名
function create(){
    $db = mysqli_connect('127.0.0.1','root','root','myphp','3306');
    if(!$db){
       return mysqli_error($db) ;
    }
    return $db;
}
$email = 'dfbb@qq.comssss';
$password = sha1('123456');
$time = time();
function insert($db,$password,$time){
    $sql = "INSERT INTO `user` VALUES (NULL,'东败',1,18,'dfbb@qq.com','{$password}',1,{$time});";
    $res = mysqli_query($db,$sql);
    return $res;
}
$arr = [];
function select($db){
    $sql = "SELECT * FROM `user` ORDER BY age DESC  LIMIT 1,2";
    $res = mysqli_query($db,$sql);
    while ($ress = mysqli_fetch_assoc($res)){
        $arr[] = $ress;
    }
    return $arr;
}
$db = create();
//$res = insert($db,$password,$time);
$res = select($db);
print_r($res);


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送