Sorrow Posted September 23, 2008 Share Posted September 23, 2008 Hi everyone. I need to display only the top 3 items of the query when i do this <?php include 'opendb.php'; $query = "SELECT * FROM reviews Order by m_index DESC "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<a href='/moviereview.php?index={$row['m_index']}'>{$row['m_Title']}</a><br>"; } mysql_close($con); ?> its ok it displays every entry but I only need the top 3 and I tried SELECT TOP 3 * FROM reviews Order by m_index DESC and SELECT TOP 3 FROM reviews Order by m_index DESC Any idea what am I doing wrong??? Quote Link to comment https://forums.phpfreaks.com/topic/125390-solved-select-top-3-problem/ Share on other sites More sharing options...
peranha Posted September 23, 2008 Share Posted September 23, 2008 You may want SELECT * FROM reviews Order by m_index DESC LIMIT 0,3 Quote Link to comment https://forums.phpfreaks.com/topic/125390-solved-select-top-3-problem/#findComment-648269 Share on other sites More sharing options...
Sorrow Posted September 23, 2008 Author Share Posted September 23, 2008 thank you very much its working Quote Link to comment https://forums.phpfreaks.com/topic/125390-solved-select-top-3-problem/#findComment-648282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.