conn.php文件 <?php $conn = @mysql_connect("localhost", "root", "root") or die("数据库链接错误"); mysql_select_db("data", $conn); //data为数据库名称 mysql_query("set names 'GBK'"); //使用GBK中文编码; ?> index.php文件 <?php include("conn.php"); //引入conn.php文件 $SQL = "SELECT * FROM `table` order by id desc"; $query = mysql_query($SQL); while ($row = mysql_fetch_array($query)) { ?> 显示数据内容: <?= $row[user] ?> <?php } ?>