php 對 mysql資料庫的增,刪,該,查

2021-06-10 08:16:36 字數 1113 閱讀 1027

$dbhost="localhost";

$dbuser ="admin";

$dbpass ="";

$dbname = "lch";

$conn = mysql_connect($dbhost,$dbuser,$dbpass,$dbname);

if($conn)

else

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());

Python實現對Mysql資料庫的增刪改查

客戶需求 使用python指令碼實現對對mysql資料庫的增刪改查 import pymysql 顯示 defreadtable cursor 選擇全部 cursor.execute select from premoney 獲得返回值,返回多條記錄,若沒有結果則返回 results cursor....

php對mysql資料庫操作

計應134軟體實驗班 劉瑞鋒 學習筆記 通過命令提示符啟動mysql資料庫,輸入安裝時設定的密碼,就可以對mysql資料庫進行資料操作,通過 show databases 可以檢視mysql資料庫中的存在多少資料庫,再輸入命令的結尾,每一條命令都要加英符的分號,不然會報錯。因為學過sqlserver...

對mysql資料庫進行增刪改查

1 新增字段 alter table student add stuage int notnull 2.修改字段 alter table student change stuage sage varchar 100 not null 3.修改表名 alter table students renam...