Php$con=mysql_connect("localhost:3306", "Root", "" "); if(!$con) { die(' Could not connect: '.Mysql_error()); } mysql_select_db("Test",$con); $result=mysql_query("SELECT * from User"); Echo"; while $rowmysql_fetch_array$result)) { echo; echo; echo; echo; } Echo
Username |
Password |
"( = ( "
" "
" . $row [' username ']. " | " "
" . $row [' Password ']. " | " "
" "
"; mysql_close($con);? >
Get all user information (SQL SELECT statement) from the server and appear in a tabular format
PHP $conmysql_connect("localhost", "root", ""); if (! $con ) { diemysql_error()); } mysql_select_db $con ); mysql_query ("DELETE from user WHERE username = '$_post[username] '"); Mysql_close ($con);? >
Delete all information for this user delete.php
PHP $conmysql_connect("localhost:3306", "Root", "" ") ; if (! $con ) { diemysql_error()); } mysql_select_db $con ); $sql = "INSERT into User (Username,password) VALUES ('$_post[username] ', '$_post[password] '; if (! mysql_query ($sql,$con)) { diemysql_error()); } Echo "1 record added"; Mysql_close ($con);? >
register a new user insert.php
PHP $conmysql_connect("localhost", "root", ""); if (! $con ) { diemysql_error()); } mysql_select_db $con ); mysql_query ("UPDATE user SET password = '$_post[password] ' WHERE username = '$_post[username] '"); mysql_close($con);? >
Modify a user password update.php
Using PHP to implement simple additions and deletions to the database
Insert:
Delete
Update
Submission Source operate.html for the above three features
The above introduces the use of PHP to the database to achieve simple additions and deletions (pure code, to be perfected), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.