Home >Backend Development >PHP Tutorial >PHP connects to the database and displays the required data_PHP tutorial
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 "-------------------
";}?>