首頁  >  文章  >  後端開發  >  php 对 mysql数据库的增,删,该,查_PHP教程

php 对 mysql数据库的增,删,该,查_PHP教程

WBOY
WBOY原創
2016-07-13 17:54:37993瀏覽

  $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','1@qq.com','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 = '2@QQ.com' 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());

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477939.htmlTechArticle$dbhost=localhost; $dbuser =admin; $dbpass =; $dbname = lch; $conn = mysql_connect($dbhost,$dbuser,$dbpass,$dbname); if($conn) { echo connect; }else { echo 11111; } mysql_select_db...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn