DOC

php

By Mike Foster,2014-06-12 09:13
10 views 0
php php php php php php php php php

    //数据库连接类

    class con

    {

    private $hostname;

    private $username;

    private $password;

    private $databasename;

    public $conn;

    function __construct($x,$y,$m,$n) {

    $this->hostname=$x;

    $this->username=$y;

    $this->password=$m;

    $this->databasename=$n;

    }

    public function getcon() {

     $this->conn=mysql_connect($this->hostname,$this->username,$this->password);

     mysql_select_db($this->databasename,$this->conn)

     or die ("数据库连接失败".mysql_error()) ;

     mysql_query("SET NAMES 'GB2312'");

     }

     }

     //连接好数据库

     /*$host="localhost";

    $user="admin";

    $password="admin";

    $dbase_name="ipdz"; $table_name="id";

$connectdb=new con($host,$user,$password,$dbase_name);

    $connectdb->getcon();*/

    //*******************************************************************//

    //查询类

    class getinfo

    {

    private $sqlstr;

    function __construct($x) {

     $this->sqlstr=$x;

}

    public function get ()

    {

     $sqlclass=mysql_query($this->sqlstr);

     $infoclass=mysql_fetch_array($sqlclass);

     return $infoclass;

    }

    }

    //************************************************************************

    //******************信息录入类*********************************************

    class reg{

     private $name;

     private $ip;

    function __construct($x,$y)

    {

     $this->name=$x;

     $this->ip=$y;

    }

     public function savereg ()

     {

     $sql="select name from id where name='$this->name' ";

     $sql=mysql_query($sql);

     if ($sql==true){

     echo "";

     exit;

     }

     $sql1="insert into id (name,ip) values ('$this->name','$this->ip')";

     if (mysql_query($sql1))

     {

     echo "";

     }

     }

     public function savereg1 ()

     {

     $sql="select * from id where name=".'$this->name';

     if(mysql_query($sql)==true)

     //判断是否录入过有问题

     {

     exit;

     echo "";

     }

     $sql1="insert into id (name,ip) values ('$this->name','$this->ip')";

     if (mysql_query($sql1))

     {

     echo "";

     }

     }

     }

     //*************************** 信息修改类 *********************************

     class changeinfo

    {

     private $name;

     private $ip;

     private $id;

function __construct($x,$y,$z)

     {

     $this->name=$x;

     $this->ip=$y;

     $this->id=$z;

     }

public function change()

     {

     // $sql="update id set name=$this->name,ip=$this->ip where id=$this->id";

     $sql="update `ipdz`.`id` set `name`='$this->name',`ip`= '$this->ip' where

    `id`.`id`='$this->id'";

     if(mysql_query($sql))

     {

     echo "";

     }

     else {

     echo "";

     }

     }

}

//删除类

    class delete{

     private $id;

     function __construct($x)

     {

     $this->id=$x;

     }

     public function shanchu(){

     $sql1="delete from `ipdz`.`id` where `id`= $this->id ";

     if(mysql_query($sql1))

     {

     echo "";;

     }

     else {

     echo "";

     }

     }

     }

?>

Report this document

For any questions or suggestions please email
cust-service@docsford.com