PHP MySQL database operation tutorial _php tutorial

Source: Internet
Author: User
Tags mysql tutorial php mysql
PHP MySQL database operation tutorial in this tutorial three examples are about PHP operation MySQL Database tutorial, one is to connect MySQL database, the second is to query the database field name, the third is to query database records.

PHP Tutorial MySQL Tutorial database tutorial Operation Tutorial
This tutorial is about three examples of PHP operation MySQL Database tutorial, one is to connect MySQL database, the second is to query the database field name, and the third is to query database records.
*/
Connect to MySQL Database

$link = mysql_connect ("localhost", "Mysql_user", "Mysql_password")
Or Die ("Could not connect:". Mysql_error ());
Print ("connected successfully");
Mysql_close ($link);



Querying MySQL field names

$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";
}

Querying data

$conn =mysql_connect ("localhost", "phpdb", "phpdb")
Or Die ("Cannot connect to database server:". mysql_error ());
mysql_select_db ("Test", $conn) or Die ("Cannot select Database:". 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.html www.bkjia.com true http://www.bkjia.com/PHPjc/630809.html techarticle PHP MySQL Database operation Tutorial This tutorial is about three examples are about PHP operation MySQL Database tutorial, one is to connect MySQL database, the second 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.