Phpmysql database operation tutorial. Phpmysql database operation tutorial this tutorial describes how to operate a mysql database using php on three instances. one is to connect to the mysql database, and the other is to query the database field name, third, query the number of php mysql database operations tutorial this tutorial describes three instances are about the php operation mysql database tutorial, one is to connect to the mysql database, the other is to query the database field name, the third is to query database records.
Php Tutorial mysql tutorial database tutorial operation tutorial
This tutorial describes how to operate a mysql database using php in three instances. one is to connect to the mysql database, the other is to query the database field name, and the third is to query database records.
*/
// Connect to the mysql database
$ Link = mysql_connect ("localhost", "mysql_user", "mysql_password ")
Or die ("cocould not connect:". mysql_error ());
Print ("connected successfully ");
Mysql_close ($ link );
// Query the mysql field name
$ Link = mysql_connect ('localhost', 'MySQL _ user', 'MySQL _ password ');
$ Fields = mysql_list_fields ("database1", "table1", $ link );
$ Columns = mysql_num_fields ($ fields );
For ($ I = 0; $ I <$ columns; $ I ++ ){
Echo mysql_field_name ($ fields, $ I). "n ";
}
// Query data
$ Conn = mysql_connect ("localhost", "phpdb", "phpdb ")
Or die ("cannot connect to the database server:". mysql_error ());
Mysql_select_db ("test", $ conn) or die ("The database cannot be selected:". mysql_error ());
$ Result = mysql_query ("select * from user", $ conn );
While ($ row = mysql_fetch_array ($ result )){
Print "name:". $ row [1];
Print "address:". $ row [3];
Print "tel:". $ row [4];
Print "email:". $ row [5];
Echo
"
";
}
Http://www.bkjia.com/PHPjc/630809.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630809.htmlTechArticlephp mysql database operation tutorial this tutorial tells three instances are on the php operation mysql database tutorial, one is to connect to mysql database, two is to query the database field name, the third is the number of queries...