php 连接数据库并显示所要的数据
这是一篇php入门教程,讲得就是关于php 连接数据库并显示所要的数据哦,也就是简单的php+mysql数据库在web网页上的应用实例了。
<?php
$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<BR>";
exit;
}
if (!$Result_ID = mysql_query($Query)) {
print "Query Error: " . mysql_error();
exit;
}
while ($Result = mysql_fetch_row($Result_ID)) {
print "------------------<BR>";
print "$Result[0]<BR>";
print "$Result[1]<BR>";
print "$Result[2]<BR>";
print "$Result[3]<BR>";
print "-------------------<BR>";
}
?>文章地址:http://www.phprm.com/database/33163.html
转载随意^^请带上本文地址!