您忘记查询数据库!
您需要使用mysql_query()
从您的数据库服务器检索数据,然后通过while()
循环遍历它。
此外,您不能在引用的字符串中使用引号 - 它会打断字符串,这意味着您将得到SELECT ...
行的语法错误。你实际上并不需要引用在查询数据库字段,所以下面应该很好地工作:
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("cede") or die("Couldn't find database");
$query = 'SELECT * FROM users ORDER BY DATE DESC LIMIT 8';
$result = mysql_query($query); // Query the database.
// Loop through each returned row
while($row = mysql_fetch_assoc($result))
{
print_r($row); // Prints the current row
}
?>
要说明的是PHP报告,把这两条线在脚本上的任何错误。
error_reporting(E_ALL);
ini_set('display_errors', '1');
他们将输出你得到任何错误,使问题多容易解决。
请不要使用root用户通过PHP连接到数据库,这可能会导致一个世界受到伤害。 –