Table of Contents
PHP MYSQL realizes the user's addition, deletion, modification and query
Home Backend Development PHP Tutorial PHP MYSQL implements user addition, deletion, modification and query_PHP tutorial

PHP MYSQL implements user addition, deletion, modification and query_PHP tutorial

Jul 13, 2016 am 10:00 AM
php+mysql share increase accomplish check user of

PHP MYSQL realizes the user's addition, deletion, modification and query

This article shares with you all the page codes for using PHP MYSQL to realize the user's addition, deletion, modification and query function. It is very detailed and very Practical and suitable for PHP beginners, please refer to it if you need it.

File list. . File content. .

dbconn.php
userListt.php
editUser.php
editDo.php
detailUser.php
deleteUser.php
addUser.php
addDo.php

?

1

2

3

4

5

6

// 创建数据库连接

$con = mysql_connect("localhost",'root','') or die('error:'.mysql_error());

mysql_select_db('hyxx',$con) or die('error:'.mysql_error());

mysql_query('set NAMES utf8');

?>

1 2 3 4 5 6
<🎜>//Create database connection<🎜> <🎜>$con = mysql_connect("localhost",'root','') or die('error:'.mysql_error());<🎜> <🎜>mysql_select_db('hyxx',$con) or die('error:'.mysql_error());<🎜> <🎜>mysql_query('set NAMES utf8');<🎜> <🎜>?>

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

会员信息列表

require_once 'inc/dbConn.php';

//这是啥东东。。

date_default_timezone_set("PRC");

//读数据。。。

$sql = "select * from user order by id asc";

$result = mysql_query($sql,$con);

$userList = '';

while($rs = mysql_fetch_array($result)){

$userList[] = $rs;

}

// 循环用户列表

foreach ($userList as $user){

echo "

";

}

?>

id 用户名 密码 性别 年龄 出生年月 爱好 注册时间 最后登录时间 操作
".$user['id']." ".$user['username']." ".$user['password']." ".$user['sex']." ".$user['age']." ".date("Y-m-d",$user['birthday'])." ".$user['hobby']." ".date("Y-m-d",$user['add_time'])." ".date("Y-m-d",$user['last_login'])."

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

edit user

require_once 'inc/dbConn.php';

$userId=$_GET['id'];

// This is 啥东东。。

date_default_timezone_set("PRC");

//read data...

$sql = "select * from user where id=".$userId;

$result = mysql_query($sql,$con);

$user = mysql_fetch_array($result);

?>

username />
codes />
性别

/> 男

/> 女

年龄 />
出生年月

$birday_y=date("Y",$user['birthday']);

$birday_m=date("m",$user['birthday']);

$birday_d=date("d",$user['birthday']);

?>

爱好 />
个人简介

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

require_once 'inc/dbConn.php';

////////////////////

///获取用户信息

////////////////////

$user_id = $_POST['user_id'];

$user_name = $_POST['user_name'];

$password= $_POST['password'];

if($_POST['sex']=='男')

{

$sex=1;

}

else if($_POST['sex']=='女')

{

$sex=2;

}

else $sex=3;

;

$age = $_POST['age'];

$birthday_y = $_POST['birthday_y'];

$birthday_m = $_POST['birthday_m'];

$birthday_d = $_POST['birthday_d'];

$birthday=mktime(0,0,0,$birthday_m,$birthday_d,$birthday_y);

$hobby = $_POST['hobby'];

$profile = $_POST['profile'];

$addTime=mktime(date("h"),date("m"),date("s"),date("m"),date("d"),date("Y"));

$lastLoginTime=$addTime;

$sql = "update user set username='$user_name',password='$password',sex='$sex',age='$age',birthday='$birthday',hobby='$hobby',profile='$profile' where id='$user_id'";

echo $sql;

// 执行sql语句

mysql_query($sql,$con);

// 获取影响的行数

$rows = mysql_affected_rows();

// 返回影响行数

// 如果影响行数>=1,则判断添加成功,否则失败

if($rows >= 1)

{

alert("编辑成功");

href("userListt.php");

}else{

alert("编辑失败");

// href("addUser.php");

}

function alert($title){

echo "";

}

function href($url){

echo "";

}

?>

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

查看用户明细

require_once 'inc/dbConn.php';

$userId=$_GET['id'];

//这是啥东东。。

date_default_timezone_set("PRC");

//读数据。。。

$sql = "select * from user where id=".$userId;

$result = mysql_query($sql,$con);

$user = mysql_fetch_array($result);

?>

用户ID
用户名
密码
性别

年龄
出生年月

$birday_y=date("Y",$user['birthday']);echo $birday_y."年";

$birday_m=date("m",$user['birthday']);echo $birday_m."月";

$birday_d=date("d",$user['birthday']);echo $birday_d."日";

?>

爱好
个人简介
返回用户列表

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

// 包含数据库文件

require_once 'inc/dbConn.php';

// 获取删除的id

$id = $_GET['id'];

$row = delete($id,$con);

if($row >=1){

alert("删除成功");

}else{

alert("删除失败");

}

// 跳转到用户列表页面

href("userListt.php");

function delete($id,$con){

$sql = "delete from user where id='$id'";

// 执行删除

mysql_query($sql,$con);

// 获取影响的行数

$rows = mysql_affected_rows();

// 返回影响行数

return $rows;

}

function alert($title){

echo "";

}

function href($url){

echo "";

}

?>

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

新增用户

用户名
密码
性别
年龄
出生年月

爱好
个人简介

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

require_once 'inc/dbConn.php';

////////////////////

///获取用户信息

////////////////////

$user_id = $_POST['user_id'];

$user_name = $_POST['user_name'];

echo $user_name;

$password= $_POST['password'];

if($_POST['sex']=='男')

{

$sex=1;

}

else if($_POST['sex']=='女')

{

$sex=2;

}

else $sex=3;

;

$age = $_POST['age'];

$birthday_y = $_POST['birthday_y'];

$birthday_m = $_POST['birthday_m'];

$birthday_d = $_POST['birthday_d'];

$birthday=mktime(0,0,0,$birthday_m,$birthday_d,$birthday_y);

$hobby = $_POST['hobby'];

$profile = $_POST['profile'];

$addTime=mktime(date("h"),date("m"),date("s"),date("m"),date("d"),date("Y"));

$lastLoginTime=$addTime;

$sql = "insert into user (username,password,sex,age,birthday,hobby,profile,add_time,last_login) ".

"values('$user_name','$password','$sex','$age','$birthday','$hobby','$profile','$addTime','$lastLoginTime')";

echo $sql;

// 执行sql语句

mysql_query($sql,$con);

// 获取影响的行数

$rows = mysql_affected_rows();

// 返回影响行数

// 如果影响行数>=1,则判断添加成功,否则失败

if($rows >= 1){

alert("添加成功");

href("userListt.php");

}else{

alert("添加失败");

// href("addUser.php");

}

function alert($title){

echo "";

}

function href($url){

echo "";

}

?>

以上所述就是本文的全部内容了,希望大家能够喜欢。

请您花一点时间将文章分享给您的朋友或者留下评论。我们将会由衷感谢您的支持!

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/973126.htmlTechArticlePHP+MYSQL实现用户的增删改查 本文给大家分享的是使用PHP+MYSQL实现用户的增删改查功能的全部页面代码,非常的详细,也很实用,适合php的初...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Xiaohongshu account to find users? Can I find my mobile phone number? How to use Xiaohongshu account to find users? Can I find my mobile phone number? Mar 22, 2024 am 08:40 AM

With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the &quot;Discover&quot; button in the lower right corner, and then select the &quot;Notes&quot; option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the &quot;Follow&quot; button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select &quot;Personal Information&quot;

How to share Quark Netdisk to Baidu Netdisk? How to share Quark Netdisk to Baidu Netdisk? Mar 14, 2024 pm 04:40 PM

Quark Netdisk and Baidu Netdisk are very convenient storage tools. Many users are asking whether these two softwares are interoperable? How to share Quark Netdisk to Baidu Netdisk? Let this site introduce to users in detail how to save Quark network disk files to Baidu network disk. How to save files from Quark Network Disk to Baidu Network Disk Method 1. If you want to know how to transfer files from Quark Network Disk to Baidu Network Disk, first download the files that need to be saved on Quark Network Disk, and then open the Baidu Network Disk client. , select the folder where the compressed file is to be saved, and double-click to open the folder. 2. After opening the folder, click "Upload" in the upper left corner of the window. 3. Find the compressed file that needs to be uploaded on your computer and click to select it.

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

How to implement dual WeChat login on Huawei mobile phones? How to implement dual WeChat login on Huawei mobile phones? Mar 24, 2024 am 11:27 AM

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

How to share NetEase Cloud Music to WeChat Moments_Tutorial on sharing NetEase Cloud Music to WeChat Moments How to share NetEase Cloud Music to WeChat Moments_Tutorial on sharing NetEase Cloud Music to WeChat Moments Mar 25, 2024 am 11:41 AM

1. First, we enter NetEase Cloud Music, and then click on the software homepage interface to enter the song playback interface. 2. Then in the song playback interface, find the sharing function button in the upper right corner, as shown in the red box in the figure below, click to select the sharing channel; in the sharing channel, click the &quot;Share to&quot; option at the bottom, and then select the first &quot;WeChat Moments&quot; allows you to share content to WeChat Moments.

How to share files with friends on Baidu Netdisk How to share files with friends on Baidu Netdisk Mar 25, 2024 pm 06:52 PM

Recently, Baidu Netdisk Android client has ushered in a new version 8.0.0. This version not only brings many changes, but also adds many practical functions. Among them, the most eye-catching is the enhancement of the folder sharing function. Now, users can easily invite friends to join and share important files in work and life, achieving more convenient collaboration and sharing. So how do you share the files you need to share with your friends? Below, the editor of this site will give you a detailed introduction. I hope it can help you! 1) Open Baidu Cloud APP, first click to select the relevant folder on the homepage, and then click the [...] icon in the upper right corner of the interface; (as shown below) 2) Then click [+] in the &quot;Shared Members&quot; column 】, and finally check all

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

Analysis of user password storage mechanism in Linux system Analysis of user password storage mechanism in Linux system Mar 20, 2024 pm 04:27 PM

Analysis of user password storage mechanism in Linux system In Linux system, the storage of user password is one of the very important security mechanisms. This article will analyze the storage mechanism of user passwords in Linux systems, including the encrypted storage of passwords, the password verification process, and how to securely manage user passwords. At the same time, specific code examples will be used to demonstrate the actual operation process of password storage. 1. Encrypted storage of passwords In Linux systems, user passwords are not stored in the system in plain text, but are encrypted and stored. L

See all articles