你好

1、连接MYSQL数据库代码


<html>

<head>

<title>Selecting MySQL Database - by www.jb51.com</title>

</head>

<body>

<?php

$dbhost = 'localhost:3036';

$dbuser = 'guest';

$dbpass = 'guest123';

$conn = mysql_connect($dbhost, $dbuser, $dbpass);

if(! $conn )

{

 die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

mysql_select_db( 'TUTORIALS' );

mysql_close($conn);

?>

</body>

</html>

2、读取数据库,并实现循环输出


&lt;?php
$sql="select * from liuyan order by ly_id desc";
$conn=mysql_query($sql,$connec);
while($rs=mysql_fetch_array($conn)){
?&gt;
循环的内容.........
&lt;?php
}
?&gt;

About the Author

Avatar photo

今生在线

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据