//查出数据库中按年龄的倒叙排列的最后两名 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);