Basic php and mysql tutorials this chapter describes how to use PHP to operate MySQL databases, including connecting to the database, closing the database connection example, executing SQL statements to obtain the query result set, and obtaining the SQL statement execution error information, obtain all records in the result set, display data by PAGE, insert data into the database, submit the HTML page of user information, display the PHP program of data information, and add the PHP program that deletes the link, deleting database data is a complete basic tutorial for getting started with php mysql.
Php and mysql basic tutorials
This chapter describes how to use php to operate a mysql database, including connecting to a database, closing the database connection example, executing SQL statements to obtain the query result set, and obtaining information about SQL statement execution errors, obtain all records in the result set, display data by PAGE, insert data into the database, submit the html page of user information, display the php program of data information, and add the php program that deletes the link, deleting database data is a complete basic tutorial for getting started with php mysql.
1. php database connection example.
2. php closes the database connection.
3. Execute SQL statements in php.
4. php obtains information about SQL statement execution errors.
5. php gets the query result set.
6. php Retrieves all records in the result set.
7. php uses a php program to display table data.
8. php displays data by page.
9. html page for submitting user information.
10. Insert php data into the database.
11. php program for displaying data in php.
12. add and delete the link in php.
13. php deletes database data.
*/
// 1.php database connection example.
$ Host = 'localhost ';
$ User_name = 'root ';
$ Password = 'admin ';
$ Conn = mysql_connect ($ host, $ user_name, $ password );
If (! $ Conn)
{
Die ('database Connection Failed: <br/> '. mysql_error ());
}
Echo 'database connection successful! ';
// 2.php closes the database connection.
$ Host = 'localhost ';
$ User_name = 'root ';
$ Password = 'admin ';
$ Conn = mysql_connect ($ host, $ user_name, $ password );
If (! $ Conn)
{
Die ('database Connection Failed: '. mysql_error ());
}
Echo 'database connection successful! ';
If (mysql_close ($ conn ))
{
Echo '<br/>... <br/> ';
Echo 'the connection to the database has been closed successfully ';
}
1 2 3 4 5 6 7 8 9