Jump to content
MakeWebGames

Recommended Posts

Posted

basicly what i did was make a db table called rates

with

TopicID | User | TS (timestamp)

i would then enter the rating into the database then upon them rating again i would look for the user and the topic if it returned a row i wouldent let them rate

Also i added the TS so that i could run a query to deleted any records over 24 hours

Posted

codeS.png

 

MySQL queries

 

 

1

 

 

ALTER TABLE `forum_topics` ADD `ft_like` INT (11) DEFAULT 0;

 

codeS.png MySQL queries

1

ALTER TABLE `forum_topics` ADD `ft_dislike` INT (11) DEFAULT 0;

i used these and not one problem

Posted

This what i am using and works on all my sites

forum2.php

 

<?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";

}

?>

Posted

Notice: Undefined index: fr_dislike in /home/iseeyou9/public_html/forum.php on line 24

You have disliked the topicQUERY ERROR: Unknown column 'fr_dislike' in 'field list'

Query was UPDATE users SET fr_dislike=concat('14') WHERE userid=1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...