I have the selecting from the last ten entries working, but am unsure how to get the most popular from these ten entries?
<?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']."] ";
}
?>
Thanks, I tried WHERE In and it doesn’t seem to work. It won’t echo any result.
$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']."] ";
}
Sorry I am new to mysql. I have 2 columns - one called id and the other called data. The table is called table_answers. It should work but it doesn’t. Thanks for your help:)
$sql = "SELECT * FROM table_answers WHERE id IN (SELECT id FROM table_answers ORDER BY id DESC LIMIT 10) ORDER BY data DESC LIMIT 1";
$result = mysql_query ($sql, $db);
while ($row = mysql_fetch_array ($result))
{
echo " [".$row['data']."] ";
}