一聚教程网:一个值得你收藏的教程网站

热门教程

php 连接数据库并显示所要的数据

时间:2022-06-24 19:13:34 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

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

  }?>

热门栏目