"PHP" Three, student management system-View users

Source: Internet
Author: User
Tags rowcount
"PHP" 3, Student management system-View users
 
  Getpagecount ($pagesize);    if (!empty ($_get[' Pagenow '))    {        $pagenow =$_get[' Pagenow '];    }    $stulist = $service->getstulist ($pagesize, $pagenow);    ? >
 
  Student Performance Management System  


Stuservice class

 EXECUTE_DQL ($sql);            $row =mysqli_fetch_row ($res);            if ($row) {$num = $row [0];            } mysqli_free_result ($res);            $mysql->close_connect ();                        return $num;  }//According to the size of each page, and the current page query out all the student 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; }//Get total pages 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); Returns the next integer not less than value, in which value is entered if there is a fractional part. Mysqli_free_result ($res); $mysql->close_connect (); return $pagecount;}    The corresponding data public function Getstu ($name) {$stu = new student () is obtained according to the student's name;    $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;    }//gets Userpublic function Getstubyid ($id) {$stu = new student () according to the ID number;    $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;}    Modify the values in the database according to the resulting object 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;}    Delete User 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 class

 link = new mysqli ($this->db_host, $this->db_user, $this->db_password, $this->db_name);/if (! $this->li NK) {//Die ("Connection Failed". Mysql_error ());//}//mysql_select_db ($this->dbname, $this->link);}    Execute SQL statement to get result set, query statement public Function EXECUTE_DQL ($sql) {$res = $this->query ($sql) or Die (Mysqli_error ($this)); return $res;}    Execute SQLDML statement INSERT, UPDATE, delete public function execute_dml ($sql) {$b = $this->query ($sql) or Die (Mysqli_error ($this));    if (! $b) {return 0;        } else {if ($this->affected_rows > 0)//If the number of rows affected is greater than 0 {return 1;//ok}         else {return 2;//No rows received affected}}}//close connection public Function Close_connect () {if (!empty ($this))    $this->close ();} }?>

Student class

 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 Configuration Database

 
  

Preview:







  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.