I want to add a new page toparticles.php which should only contain the Top Viewed Articles from my site
Can you help me with the code.
Display Only Top Articles on a New Page
Moderator: mkoch227
Display Only Top Articles on a New Page
Regards
Hefin Dsouza
http://hefin.in
Hefin Dsouza
http://hefin.in
Haven't tested it, but this is the extracted code form the index.php file, save it as "top_articles.php" inside the main Hesk folder:
You should be able to change the number of top articles displayed by changing the setting fro $limit at the top of the script.
Code: Select all
<?php
$limit = 10;
define('IN_SCRIPT',1);
define('HESK_PATH','');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');
hesk_dbConnect();
?>
<table border="0" width="100%">
<tr>
<td>» <i><?php echo $hesklang['popart']; ?></i></td>
<td style="text-align:right"><i><?php echo $hesklang['views']; ?></i></td>
</tr>
</table>
<?php
$sql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` WHERE `type`=\'0\' ORDER BY `views` DESC, `art_order` ASC LIMIT '.hesk_dbEscape($limit);
$res = hesk_dbQuery($sql);
echo '<div align="center"><table border="0" cellspacing="1" cellpadding="3" width="100%">';
while ($article = hesk_dbFetchAssoc($res))
{
echo '
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="1" valign="top"><img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" /></td>
<td valign="top"> <a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a></td>
<td valign="top" style="text-align:right" width="200">'.$article['views'].'</td>
</tr>
</table>
</td>
</tr>';
}
echo '</table></div>';
/* Print footer */
require_once(HESK_PATH . 'inc/footer.inc.php');
exit();
?>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Thanks A Lot
Thanks This Code Works perfectly.
I was planning to Develop a Facebook Application displaying the Top Articles from my FAQ and list it in the Application...Thanks a Lot for the Solution
I was planning to Develop a Facebook Application displaying the Top Articles from my FAQ and list it in the Application...Thanks a Lot for the Solution
Regards
Hefin Dsouza
http://hefin.in
Hefin Dsouza
http://hefin.in