程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php 對 mysql數據庫的增,刪,該,查

php 對 mysql數據庫的增,刪,該,查

編輯:關於PHP編程

  $dbhost="localhost";
        $dbuser ="admin";
        $dbpass ="";
        $dbname = "lch";
        $conn = mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
       
        if($conn)
        {
            echo "connect";
        }else
        {
            echo "11111";
        }
        mysql_select_db($dbname,$conn);
        $sql = "insert into ";
        $sql .="user(tripal_id,company_id,username,email,name,credit,parent_id,password,settle_password,lognum,last_login,new_fan_num,remember_me_num,
        is_admin,is_bb,is_bc)";

        $sql .="values('1','1','name3','[email protected]','ling','23','0',null,null,'1','2012-10-18 16:25:39','1','1','1','1','1')";

        mysql_query($sql) or die('insert data failed cause: '.mysql_error());
       
        $select = "select * from user ";
        $result =  mysql_query($select) or die('select data failed cause: '.mysql_error());
        print_r(mysql_fetch_array($result));
       
        $update = "update user set email = '[email protected]' where id =3";
        echo $update;
        mysql_query($update) or die('update data failed cause: '.mysql_error());
       
    
        $delete = "delete from user where id = 1";
        mysql_query($delete) or die('delete data failed cause: '.mysql_error());

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved