PHP connects to the database and displays the data you want _php tutorial

Source: Internet
Author: User
This is a PHP getting Started tutorial, is about the PHP connection database and display the desired data oh, that is, a simple php+mysql database on the Web page application example.

This is an introductory tutorial on PHP tutorial, it is about the PHP Connection Database tutorial and display the data you want, that is, a simple php+mysql tutorial database on the Web page application example.

$Host = "localhost";

$MySQL _username= "root";

$MySQL _userpass= "Password";

$MySQL _database= "DB";

$Query = "SELECT * from Domain";

if (!mysql_connect ($Host, $MySQL _username, $MySQL _userpass)) {

Print "Cannot connect to MySQL:". Mysql_error ();

Exit

}

if (!mysql_select_db ($MySQL _database)) {

Print "Cannot select DB
";

Exit

}

if (! $Result _id=mysql_query ($Query)) {

Print "Query Error:". Mysql_error ();

Exit

}

while ($Result =mysql_fetch_row ($Result _id)) {

Print "------------------
";

print "$Result [0]
";

Print "$Result [1]
";

Print "$Result [2]
";

Print "$Result [3]
";

Print "-------------------
";

}?>

http://www.bkjia.com/PHPjc/630869.html www.bkjia.com true http://www.bkjia.com/PHPjc/630869.html techarticle This is a PHP getting Started tutorial, is about the PHP connection database and display the desired data oh, that is, a simple php+mysql database on the Web page application example. This is an article ...

  • 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.