one problem people can keep rating the same one over and over and people can rate there own topic if you know how to fix that please post the fix im just re learning to code so i forget how to do it
First add
ALTER TABLE `forum_topics` ADD `ft_like` INT (11) DEFAULT 0;
ALTER TABLE `forum_topics` ADD `ft_dislike` INT (11) DEFAULT 0;
ALTER TABLE `users` ADD `fr_like` INT (11) DEFAULT 0;
ALTER TABLE `users` ADD `fr_dislike` INT (11) DEFAULT 0;
in your db in forum_topics
then open forums.php and scrool down to
function viewforum()
{
and scrool down untill you see
$posts=number_format($r2['ft_posts']);
print "<tr bgcolor='lightsteelblue'> <td align='center'>$pt<a href='forums.php?viewtopic={$r2['ft_id']}&lastpost=1'>{$r2['ft_name']}</a>$lt<br />
<small>{$r2['ft_desc']}</small></td>
after that add
<td align='center'><font color='green'>+{$r2['ft_like']}</font><br/><font color='red'>-{$r2['ft_dislike']}</font></td>
then go into
function viewtopic()
{
and find
$qlink="[<a href='forums.php?act=quote&viewtopic={$_GET['viewtopic']}&post={$r['fp_id']}'>Quote Post</a>]";
and under it add
$rlink="[<a href='forum2.php?LID={$_GET['viewtopic']}'>Like</a>]
[<a href='forum2.php?DID={$_GET['viewtopic']}'>Dislike</a>]";
then find
print "<tr bgcolor='steelblue'>
<th align='center' width=20%>Post #{$no}</th> <th align='center'>Subject: {$r['fp_subject']}<br />
$t $qlink$slink$elink$dlink
after $dlink
add
$rlink
then make a file called forum2.php and put this inside it
<?php
$i=('globals.php');
include "$i";
$_GET['LID'] = abs((int) $_GET['LID']);
$_GET['DID'] = abs((int) $_GET['DID']);
if($_GET['LID'])
{
global $ir, $userid, $h, $db;
$p = $db->query("SELECT ft_id, ft_name FROM forum_topics WHERE ft_id = ".$_GET['LID']);
$r = $db->fetch_row($p);
if ($r['ft_id'] == $ir['fr_like'])
{echo "You already voted on this topic";}
else {
echo "You have liked the topic";
$db->query("UPDATE forum_topics SET ft_like=ft_like+1 WHERE ft_id={$r['ft_id']}");
$db->query("UPDATE users SET fr_like=concat('{$r['ft_id']}') WHERE userid=$userid");
}
}
else if($_GET['DID'])
{
global $ir, $userid, $h, $db;
$p = $db->query("SELECT ft_id, ft_name FROM forum_topics WHERE ft_id = ".$_GET['DID']);
$r = $db->fetch_row($p);
if ($r['ft_id'] == $ir['fr_dislike'])
{echo "You already voted on this topic";}
else {
echo "You have disliked the topic";
$db->query("UPDATE forum_topics SET ft_dislike=ft_dislike+1 WHERE ft_id={$r['ft_id']}");
$db->query("UPDATE users SET fr_dislike=concat('{$r['ft_id']}') WHERE userid=$userid");
}
}
else
{
echo "Invalid use of file";
}
?>
and i am pretty sure thats it
if you know ways to make it better let me know