您好,欢迎访问一九零五行业门户网

【php】三、学生管理系统-查看用户

【php】3、学生管理系统-查看用户
getpagecount($pagesize); if(!empty($_get['pagenow'])) { $pagenow=$_get['pagenow']; } $stulist = $service->getstulist($pagesize, $pagenow); ?> 学生成绩管理系统
学生id号 学生姓名 学生密码
跳转到:
stuservice类
execute_dql($sql); $row=mysqli_fetch_row($res); if($row) { $num=$row[0]; } mysqli_free_result($res); $mysql->close_connect(); return $num; } //根据每页的大小,和当前的页面查询出所有的学生 public function getstulist($pagesize,$pagenow) { $mysql = new mysql(db_host, db_user, db_password, db_name); $sql=select * from student limit .($pagenow-1)*$pagesize.,$pagesize; $res=$mysql->execute_dql($sql); $arr=array(); $i=0; while($row = mysqli_fetch_assoc($res)) { $arr[$i++]=$row; } mysqli_free_result($res); $mysql->close_connect(); return $arr; } //得到总页数 public function getpagecount($pagesize) { $mysql = new mysql(db_host, db_user, db_password, db_name); $sql=select count(stu_id) from student; $res=$mysql->execute_dql($sql); $i=0; $row = mysqli_fetch_row($res); if($row) { $rowcount=$row[0]; } $pagecount=ceil($rowcount/$pagesize); //返回不小于 value 的下一个整数,value 如果有小数部分则进一位。 mysqli_free_result($res); $mysql->close_connect(); return $pagecount; } //根据学生姓名得到相应数据 public function getstu($name) { $stu = new student(); $mysql = new mysql(db_host, db_user, db_password, db_name); $sql=select * from student where stu_name='.$name.'; $res=$mysql->execute_dql($sql); if($row = mysqli_fetch_assoc($res)) { $stu->setstu_id($row['stu_id']); $stu->setstu_name($row['stu_name']); $stu->setstu_password($row['stu_password']); } mysqli_free_result($res); $mysql->close_connect(); return $stu; } //根据id号获取user public function getstubyid($id) { $stu = new student(); $mysql = new mysql(db_host, db_user, db_password, db_name); $sql=select * from student where stu_id='.$id.'; $res=$mysql->execute_dql($sql); if($row = mysqli_fetch_assoc($res)) { $stu->setstu_id($row['stu_id']); $stu->setstu_name($row['stu_name']); $stu->setstu_password($row['stu_password']); } mysqli_free_result($res); $mysql->close_connect(); return $stu; } //根据得到的对象修改数据库中的值 public function update(student $stu) { $mysql = new mysql(db_host, db_user, db_password, db_name); $sql=update student set stu_name='.$stu->getstu_name().',stu_password='.$stu->getstu_password().' where stu_id=.$stu->getstu_id(); $b = $mysql->execute_dml($sql);// if($b == 1)// {// return true;// } return $b; } //删除用户 public function delete(student $stu) { $mysql = new mysql(db_host, db_user, db_password, db_name); $sql = delete from student where stu_id=.$stu->getstu_id().;; $b = $mysql->execute_dml($sql); return $b; } }?>
mysql类
link = new mysqli($this->db_host, $this->db_user, $this->db_password, $this->db_name);// if(!$this->link){// die(连接失败.mysql_error());// } //mysql_select_db($this->dbname,$this->link); } //执行sql语句得到结果集,查询语句 public function execute_dql($sql) { $res = $this->query($sql) or die(mysqli_error($this)); return $res; } //执行sqldml语句插入,更新,删除 public function execute_dml($sql) { $b = $this->query($sql) or die(mysqli_error($this)); if(!$b) { return 0; } else { if($this->affected_rows > 0) //如果收影响的行数大于0 { return 1; //ok了 } else { return 2; //没有行收到影响 } } } //关闭连接 public function close_connect() { if(!empty($this)) $this->close(); } } ?>
student类
stu_id; } /** * @return the $stu_name */ public function getstu_name() { return $this->stu_name; } /** * @return the $stu_password */ public function getstu_password() { return $this->stu_password; } /** * @param field_type $stu_id */ public function setstu_id($stu_id) { $this->stu_id = $stu_id; } /** * @param field_type $stu_name */ public function setstu_name($stu_name) { $this->stu_name = $stu_name; } /** * @param field_type $stu_password */ public function setstu_password($stu_password) { $this->stu_password = $stu_password; } } ?>
config.php配置数据库

预览:
其它类似信息

推荐信息