Home  >  Article  >  Backend Development  >  PHP connects to the database and displays the required data_PHP tutorial

PHP connects to the database and displays the required data_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:151423browse

This is an introductory tutorial on PHP. It talks about connecting PHP to a database and displaying the required data. It is also an application example of a simple PHP+mysql database on a web page.

This is an introductory php tutorial. It talks about php connecting to database tutorial and displaying the data required by , which is a simple php+mysql tutorial database on the web Application examples on the web page.

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

 }?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630869.htmlTechArticleThis is an introductory tutorial on PHP. It talks about connecting PHP to the database and displaying the required data, that is Here is an application example of a simple php+mysql database on a web page. This is an article...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn