这是一篇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)) { //开源代码phprm.com 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>"; }
本文地址:
转载随意,但请附上文章地址:-)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号