Here is a simple PHP database operation procedures, we are talking about php connect mysql database, and then execute the sql query and then we want the records displayed, and finally closed And mysql 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 is successful! Continue to operate ... ';
mysql_select_db ('test');
$ sql = 'select id, name, city from users';
$ result = mysql_query ($ sql);
if ($ result)
{
echo 'sql statement:'. $ sql. 'has been successfully executed! ';
$ num = mysql_num_rows ($ result); // Call the function mysql_num_row () to get the number of rows in the select statement's query result
echo 'The sql query to <b>'. $ num. '</ b> www.jzread.com Line data';
}
if (mysql_close ($ conn))
{
echo '........';
echo 'to the database connection has been successfully closed';
}