Phpmysql database operation tutorial _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.