我可以从最后十个条目中进行选择,但不确定如何从这十个条目中获得最受欢迎的?另外,我将如何计算最受欢迎的条目的数量并将其输出到百分比?
<?php
$sql = "SELECT data FROM table_answers ORDER BY id DESC LIMIT 10";
$result = mysql_query ($sql, $db);
while ($row = mysql_fetch_array ($result))
{
echo "[".$row['data']."]";
}
?>
而且我也尝试过 WHERE 值,但它没有返回任何结果。
$sql = "SELECT data FROM table_answers WHERE id IN (SELECT id FROM table_answers
ORDER BY id DESC LIMIT 10) ORDER BY popularity DESC LIMIT 1";
$result = mysql_query ($sql, $db);
while ($row = mysql_fetch_array ($result))
{
echo " [".$row['data']."] ";
}
有人知道我在这里可能做错了什么吗?请