skshost Posted June 9, 2007 Share Posted June 9, 2007 Someone asked me about this and I couldn't find where it was posted on the forums. Here's the query to get the most popular knowledgebase articles, put it on your homepage.tpl if you'd like. Then add the foreach statement from knowledgebase.tpl {php} // Get Articles with highest count $i=0; $client_query = "SELECT * FROM tblknowledgebase ORDER BY views LIMIT 10"; $result = mysql_query($client_query); while($row = mysql_fetch_array($result)) { $kbmostviews_array[$i]['id'] = $row['id']; $kbmostviews_array[$i]['category'] = $row['category']; $kbmostviews_array[$i]['title'] = $row['title']; $kbmostviews_array[$i]['article'] = strip_tags($row['article']); $kbmostviews_array[$i]['views'] = $row['views']; $i++; } //Pass the values to smarty $this->assign('kbmostviews',$kbmostviews_array); {/php} 0 Quote Link to comment Share on other sites More sharing options...
Joweb Posted June 23, 2007 Share Posted June 23, 2007 This looks good on the support page but it does not give me the the ten highest viewed articles. It gives me the lowest ten? 0 Quote Link to comment Share on other sites More sharing options...
STECHUSA Posted June 24, 2007 Share Posted June 24, 2007 Hey joweb, There seems to be a coding error in the following code: $client_query = "SELECT * FROM tblknowledgebase ORDER BY views LIMIT 10"; If you use the code below instead of the above, you should get the desired result: $client_query = "SELECT * FROM tblknowledgebase ORDER BY views DESC LIMIT 10"; skshost, perhaps you can update your original post to include the fix? 0 Quote Link to comment Share on other sites More sharing options...
Joweb Posted June 24, 2007 Share Posted June 24, 2007 STECHUSA, Thanks that did the job. 0 Quote Link to comment Share on other sites More sharing options...
STECHUSA Posted June 24, 2007 Share Posted June 24, 2007 No problem, joweb. 0 Quote Link to comment 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.