mysql php中的DISTINCT中没有输出
我无法在mysql中显示我的独特查询,请帮助mysql php中的DISTINCT中没有输出,mysql,distinct,Mysql,Distinct,我无法在mysql中显示我的独特查询,请帮助 <?php mysql_connect("localhost","root","123"); mysql_select_db("sarangani"); $result = mysql_query("SELECT DISTINCT year(posted) AS year FROM news ORDER BY posted"); while($row = mysql_fetch_array($result)) { echo "$row[
<?php
mysql_connect("localhost","root","123");
mysql_select_db("sarangani");
$result = mysql_query("SELECT DISTINCT year(posted) AS year FROM news ORDER BY posted");
while($row = mysql_fetch_array($result)) {
echo "$row[year]";
}
?>
如果您确定查询应该提供结果,则需要使用正确的方法
回送结果:
while ($row = mysql_fetch_array($result)) {
echo $row['year']; // So don't put it inside double quotes
}
@SheerwoodJohnCaday“什么都没有”是什么意思?你需要尽可能具体。你想要什么,你得到了什么?那么你的查询可能不会产生结果,或者在过程中出现了错误。您可以尝试以下几点:1°更改代码以显示错误(搜索此错误)-2°如果直接在数据库中运行查询会发生什么情况?我想显示数据库中存储的年份,但我不知道我的代码有什么问题。我得到一个空白结果。它没有显示结果。我没有错误。我唯一的输出是空的。它没有显示我的欲望输出。请帮助更改php.ini文件:display_error=On和error_reporting=E_ALL&~E_NOTICE&~E_STRICT&~E_DEPRECATED(然后重新启动web服务器),并告诉我们您的问题是什么。